Skip to content

Commit

Permalink
test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mihaicalinluca committed Jun 5, 2024
1 parent 72327d3 commit f9ea270
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions framework/base/src/types/managed/wrapped/managed_decimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,15 @@ impl<M: ManagedTypeApi, D: Decimals> ManagedDecimal<M, D> {
let x = self.to_big_float() / divisor; // normalize to [1.0, 2.0]

let ln_of_2 = BigFloat::from_frac(69314718i64, 100_000_000i64); // 0.69314718 8 decimals
let first = BigFloat::from_frac(-17417939i64, 10_000_000i64); // 1.7417939, 7 decimals
let first = BigFloat::from_frac(17417939i64, 10_000_000i64); // 1.7417939, 7 decimals
let second = BigFloat::from_frac(28212026i64, 10_000_000i64); // 2.8212026, 7 decimals
let third = BigFloat::from_frac(-14699568i64, 10_000_000i64); // 1.4699568, 7 decimals
let third = BigFloat::from_frac(14699568i64, 10_000_000i64); // 1.4699568, 7 decimals
let fourth = BigFloat::from_frac(44717955i64, 100_000_000i64); // 0.44717955, 8 decimals
let fifth = BigFloat::from_frac(-56570851i64, 1_000_000_000i64); // 0.056570851, 9 decimals
let fifth = BigFloat::from_frac(56570851i64, 1_000_000_000i64); // 0.056570851, 9 decimals

// approximating polynom for getting the result
let result =
(((fourth + fifth * x.clone()) * x.clone() + third) * x.clone() + second) * x + first;
(((fourth - fifth * x.clone()) * x.clone() - third) * x.clone() + second) * x - first;
let add_member = BigFloat::from_big_uint(&BigUint::from(log2)) * ln_of_2;
let final_result = result + add_member;

Expand Down
2 changes: 1 addition & 1 deletion framework/scenario/tests/managed_decimal_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ fn test_managed_decimal_ln() {
assert_eq!(
ln_fixed,
ManagedDecimal::<StaticApi, NumDecimals>::from_raw_units(
BigUint::from(313549421u64),
BigUint::from(31355146488u64),
10usize
)
);
Expand Down

0 comments on commit f9ea270

Please sign in to comment.