ParseAssetAmount return raw float string to uint64 multiplied by math.Pow10(precision) For example 1000000000.123456789 => 1000000000123456789
(rawAmount string, precision byte)
| 59 | //ParseAssetAmount return raw float string to uint64 multiplied by math.Pow10(precision) |
| 60 | //For example 1000000000.123456789 => 1000000000123456789 |
| 61 | func 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 | |
| 71 | func FormatOng(amount uint64) string { |
| 72 | return FormatAssetAmount(amount, PRECISION_ONG) |