Use `unsigned_abs` instead of manual code
The code originally used `if` and incorrectly casted the value into `usize` rather than `u64`. This change replaces the whole thing with `unsigned_abs`. Closes #1247
This commit is contained in:
parent
e2b9555070
commit
dda83707a2
|
@ -135,7 +135,7 @@ pub fn write_scriptint(out: &mut [u8; 8], n: i64) -> usize {
|
|||
|
||||
let neg = n < 0;
|
||||
|
||||
let mut abs = if neg { -n } else { n } as usize;
|
||||
let mut abs = n.unsigned_abs();
|
||||
while abs > 0xFF {
|
||||
out[len] = (abs & 0xFF) as u8;
|
||||
len += 1;
|
||||
|
|
Loading…
Reference in New Issue