Stop casting to the wrong type. SP int code use sp_int_digit and sp_digit can be a different signedness.