Closed abailly closed 2 weeks ago
In the ln function for FixedDecimal we ignore the bool return by ref_ln which handles the special case of 0 by returning false.
FixedDecimal
bool
ref_ln
This leads to the odd situation of having FixedDecimal::new(0).ln() being 0.
FixedDecimal::new(0).ln()
the following diff illustrates the point
diff --git a/pallas-math/src/math.rs b/pallas-math/src/math.rs index 8f103b8..2dd6042 100644 --- a/pallas-math/src/math.rs +++ b/pallas-math/src/math.rs @@ -479,4 +479,12 @@ mod tests { assert_eq!(res.iterations.to_string(), expected_iterations); } } + + + #[test] + fn ln_of_0_should_not_be_0 () { + let zero : FixedDecimal = FixedDecimal::from(0u64); + assert_ne!(zero, zero.ln()); + } + }
It turns out the test fails on the current tip of main
main
https://github.com/txpipe/pallas/pull/533
resolved
In the ln function for
FixedDecimal
we ignore thebool
return byref_ln
which handles the special case of 0 by returning false.This leads to the odd situation of having
FixedDecimal::new(0).ln()
being 0.the following diff illustrates the point
It turns out the test fails on the current tip of
main