MCPcopy Create free account
hub / github.com/DNAProject/DNA / ParseAssetAmount

Function ParseAssetAmount

cmd/utils/utils.go:61–69  ·  view source on GitHub ↗

ParseAssetAmount return raw float string to uint64 multiplied by math.Pow10(precision) For example 1000000000.123456789 => 1000000000123456789

(rawAmount string, precision byte)

Source from the content-addressed store, hash-verified

59//ParseAssetAmount return raw float string to uint64 multiplied by math.Pow10(precision)
60//For example 1000000000.123456789 => 1000000000123456789
61func ParseAssetAmount(rawAmount string, precision byte) uint64 {
62 bf, ok := new(big.Float).SetString(rawAmount)
63 if !ok {
64 return 0
65 }
66 bf.Mul(bf, new(big.Float).SetFloat64(math.Pow10(int(precision))))
67 amount, _ := bf.Uint64()
68 return amount
69}
70
71func FormatOng(amount uint64) string {
72 return FormatAssetAmount(amount, PRECISION_ONG)

Callers 2

ParseOngFunction · 0.85
ParseOntFunction · 0.85

Calls 1

MulMethod · 0.80

Tested by

no test coverage detected