Merge rust-bitcoin/rust-bitcoin#2410: Use `unsigned_abs` instead of manual code
dda83707a2
Use `unsigned_abs` instead of manual code (Martin Habovstiak) Pull request description: 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 ACKs for top commit: apoelstra: ACKdda83707a2
tcharding: ACKdda83707a2
Tree-SHA512: c57bf440705c69917206aab36bbbe5b048ed52d7a96ebd055416b8a249fc3f7ba32ebff3d2251b971e7ef999ff8169ac3db8e599ab38cf0776ecc030447a9a4a
This commit is contained in:
commit
34d98356cd
|
@ -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