From 455775bb65049289e657ced6b268026c134cf15b Mon Sep 17 00:00:00 2001 From: Felipe Neuwald Date: Sun, 17 Jan 2021 00:05:58 +0000 Subject: [PATCH 1/2] func (d Decimal) MustFloat64() --- decimal.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/decimal.go b/decimal.go index 22f49e58..d60486ef 100644 --- a/decimal.go +++ b/decimal.go @@ -804,6 +804,13 @@ func (d Decimal) Float64() (f float64, exact bool) { return d.Rat().Float64() } +// MustFloat64 returns the nearest float64 value for d. +// It doesn't indicate if the returned value represents d exactly. +func (d Decimal) MustFloat64() float64 { + f, _ := d.Float64() + return f +} + // String returns the string representation of the decimal // with the fixed point. // From d1a220c451baade5155d500eb19bb47ed802c065 Mon Sep 17 00:00:00 2001 From: Felipe Neuwald Date: Sun, 7 Feb 2021 09:16:49 +0000 Subject: [PATCH 2/2] renames MustFloat64 to InexactFloat64 --- decimal.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/decimal.go b/decimal.go index d60486ef..3356961c 100644 --- a/decimal.go +++ b/decimal.go @@ -804,9 +804,9 @@ func (d Decimal) Float64() (f float64, exact bool) { return d.Rat().Float64() } -// MustFloat64 returns the nearest float64 value for d. +// InexactFloat64 returns the nearest float64 value for d. // It doesn't indicate if the returned value represents d exactly. -func (d Decimal) MustFloat64() float64 { +func (d Decimal) InexactFloat64() float64 { f, _ := d.Float64() return f }