Skip to content

Commit

Permalink
fix abs
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelDkhn committed Oct 8, 2024
1 parent 96bfa1c commit 9a2db04
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/numbers/src/f64/ops.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ pub(crate) fn abs(a: F64) -> F64 {
return F64 { d: NaN };
}

if a.d <= 0 {
F64 { d: a.d * ONE }
if a.d < 0 {
F64 { d: -a.d }
} else {
a
}
Expand Down Expand Up @@ -418,6 +418,14 @@ mod tests {
assert(exp2(a).d == 72057594037927936, 'invalid exp2 of 2');
}

#[test]
#[available_gas(400000)]
fn test_exp2_neg() {
let a: F64 = FixedTrait::new(-925062941);
println!("A: {:}", exp2(a).d);
assert(exp2(a).d == -6835341966, 'invalid exp2 of 2');
}

#[test]
#[available_gas(20000)]
fn test_exp2_int() {
Expand Down

0 comments on commit 9a2db04

Please sign in to comment.