Open puneet2019 opened 9 months ago
The tricky part here is how to do rounding and the type of divisor. Decimal/Decimal, Decimal/int? Not straight forward.
But if rounding is fine for you, just call toFloatApproximation()
and then operate on the JavaScript number
.
I think decimal/decimal, because int conversion to decimal is easy. then the final result can be converted to approx float anyway..
The problem with using floats is the 18 decimal tokens.
I guess I am using decodeCosmosSdkDecFromProto
for sdk.Int as well..i guess it will auto resolve when BigInts will be used..
There is plus, minus, multiply, but there is no divide. https://github.com/cosmos/cosmjs/blob/main/packages/math/src/decimal.ts#L185-L209 Can we have divide fucntion? even if it is approximate? (approxDiv).