File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
packages/injective-math/src/fp_decimal Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,12 @@ impl From<Uint128> for FPDecimal {
72
72
}
73
73
}
74
74
75
+ impl From < FPDecimal > for Uint256 {
76
+ fn from ( value : FPDecimal ) -> Self {
77
+ value. to_u256 ( )
78
+ }
79
+ }
80
+
75
81
impl From < Uint256 > for FPDecimal {
76
82
fn from ( x : Uint256 ) -> FPDecimal {
77
83
FPDecimal :: from_str ( & x. to_string ( ) ) . unwrap ( )
@@ -456,6 +462,18 @@ mod tests {
456
462
assert_eq ! ( uint256, Uint256 :: from( 12345u64 ) ) ;
457
463
}
458
464
465
+ #[ test]
466
+ fn test_into_u256 ( ) {
467
+ let fp_decimal: Uint256 = FPDecimal {
468
+ num : U256 :: from ( 12345u64 ) ,
469
+ sign : 1 , // Assuming it's always positive
470
+ }
471
+ . into ( ) ;
472
+ let u256 = Uint256 :: from ( 12345u64 ) ;
473
+
474
+ assert_eq ! ( u256, fp_decimal)
475
+ }
476
+
459
477
#[ test]
460
478
fn into_uint256_floor ( ) {
461
479
let fp_decimal = FPDecimal {
You can’t perform that action at this time.
0 commit comments