From 501661573f6073b905cf2543d17904af87099881 Mon Sep 17 00:00:00 2001 From: Felipe Neuwald <46167104+felipeneuwald@users.noreply.github.com> Date: Tue, 30 Mar 2021 00:12:37 +0100 Subject: [PATCH] Add InexactFloat64 method (#205) * Add func (d Decimal) MustFloat64() * renames MustFloat64 to InexactFloat64 --- decimal.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/decimal.go b/decimal.go index db4efc6f..4876f8c9 100644 --- a/decimal.go +++ b/decimal.go @@ -804,6 +804,13 @@ func (d Decimal) Float64() (f float64, exact bool) { 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 // with the fixed point. //