fixedpoint source pure
Package fixedpoint provides deterministic decimal arithmetic with a fixed number of decimal places, backed by int64. ...
Package fixedpoint provides deterministic decimal arithmetic with a fixed number of decimal places, backed by int64. gno.land has no float type reachable from consensus-critical code (and even if it did, floats aren't deterministic across platforms), so any realm doing price/ratio/percentage math needs something like this instead of drifting into ad-hoc basis-points arithmetic scattered everywhere.
A Fixed value stores its number scaled by 10^Decimals in Raw. All arithmetic is overflow-checked via math/overflow and panics rather than silently wrapping -- a wrapped overflow in financial math is a far worse failure mode than a loud panic.
2
2
1
2
- gno.land/p/nt/ufmt/v0 package
- math/overflow stdlib