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:
Martin Habovstiak 2024-01-27 20:49:15 +01:00
parent e2b9555070
commit dda83707a2
1 changed files with 1 additions and 1 deletions

View File

@ -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;