Add InexactFloat64 method (#205)

* Add func (d Decimal) MustFloat64()
* renames MustFloat64 to InexactFloat64
This commit is contained in:
Felipe Neuwald 2021-03-30 00:12:37 +01:00 committed by GitHub
parent f77bb07828
commit 501661573f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -804,6 +804,13 @@ func (d Decimal) Float64() (f float64, exact bool) {
return d.Rat().Float64() return d.Rat().Float64()
} }
// InexactFloat64 returns the nearest float64 value for d.
// It doesn't indicate if the returned value represents d exactly.
func (d Decimal) InexactFloat64() float64 {
f, _ := d.Float64()
return f
}
// String returns the string representation of the decimal // String returns the string representation of the decimal
// with the fixed point. // with the fixed point.
// //