SetFloat64 sets d's Coefficient and Exponent to x and returns d. d will hold the exact value of f.
(f float64)
| 247 | // SetFloat64 sets d's Coefficient and Exponent to x and returns d. d will |
| 248 | // hold the exact value of f. |
| 249 | func (d *Decimal) SetFloat64(f float64) (*Decimal, error) { |
| 250 | var buf [32]byte // Avoid most of the allocations in strconv. |
| 251 | _, _, err := d.SetString(string(strconv.AppendFloat(buf[:0], f, 'E', -1, 64))) |
| 252 | return d, err |
| 253 | } |
| 254 | |
| 255 | // Int64 returns the int64 representation of x. If x cannot be represented in an |
| 256 | // int64, an error is returned. |