NewFromFloat converts a float64 to Decimal. The converted number will contain the number of significant digits that can be represented in a float with reliable roundtrip. This is typically 15 digits, but may be more in some cases. See https://www.exploringbinary.com/decimal-precision-of-binary-floa
(value float64)
| 297 | // |
| 298 | // NOTE: this will panic on NaN, +/-inf |
| 299 | func NewFromFloat(value float64) Decimal { |
| 300 | if value == 0 { |
| 301 | return New(0, 0) |
| 302 | } |
| 303 | return newFromFloat(value, math.Float64bits(value), &float64info) |
| 304 | } |
| 305 | |
| 306 | // NewFromFloat32 converts a float32 to Decimal. |
| 307 | // |
searching dependent graphs…