@@ -32,11 +32,6 @@ impl Decimal256 {
32
32
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 192 , 151 , 206 , 123 , 201 , 7 , 21 , 179 ,
33
33
75 , 159 , 16 , 0 , 0 , 0 , 0 ,
34
34
] ) ;
35
- const DECIMAL_FRACTIONAL_UINT512 : Uint512 = Uint512 :: from_be_bytes ( [
36
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
37
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 13 , 224 , 182 ,
38
- 179 , 167 , 100 , 0 , 0 ,
39
- ] ) ; // Python: `[b for b in (1*10**18).to_bytes(32, "big")]`
40
35
41
36
pub const MAX : Self = Self ( Uint256 :: MAX ) ;
42
37
@@ -231,8 +226,8 @@ impl ops::Mul for Decimal256 {
231
226
// (a.numerator() * b.numerator()) / (a.denominator() * b.denominator())
232
227
// = (a.numerator() * b.numerator()) / a.denominator() / b.denominator()
233
228
234
- let result_as_uint512 =
235
- self . numerator ( ) . full_mul ( other . numerator ( ) ) / Self :: DECIMAL_FRACTIONAL_UINT512 ;
229
+ let result_as_uint512 = self . numerator ( ) . full_mul ( other . numerator ( ) )
230
+ / Uint512 :: from_uint256 ( Self :: DECIMAL_FRACTIONAL ) ; // from_uint256 is a const method and should be "free"
236
231
match result_as_uint512. try_into ( ) {
237
232
Ok ( result) => Self ( result) ,
238
233
Err ( _) => panic ! ( "attempt to multiply with overflow" ) ,
0 commit comments