--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/82e16a17-387e-41cb-a79c-723c2e8a772bn%40googlegroups.com.
When I print both values, they print exactly same. so I am assuming no precision lost for this specific example 123.4.but still Cmp returns non-zero.
On Monday, February 15, 2021 at 2:03:24 AM UTC+5:30 Kurtis Rader wrote:The value 123.4 cannot be represented exactly as a float64. See https://golang.org/pkg/math/big/#NewFloat for the caveats involved in using NewFloat() or SetFloat64(). Passing a string representation allows the implementation to preserve the exact value without rounding.On Sun, Feb 14, 2021 at 12:21 PM Santhosh Kumar T <santhos...@gmail.com> wrote:I created:one instance using big.NewFloat functionanother instance using big.Float.SetString methodwhen compared both these instances using big.Float.Cmp, it return non-zeroam I doing something wrong ?can some one explain why Cmp returns non-zero ?
NewFloat allocates and returns a new Float set to x, with precision 53
If z's precision is 0, it is changed to 64 before rounding takes effect.
The 'v' format is handled like 'g'.
A negative precision selects the smallest number of decimal digits necessary to identify the value x uniquely using x.Prec() mantissa bits.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/b6a82206-6660-4a08-85bd-86e482b8527en%40googlegroups.com.
I created:one instance using big.NewFloat functionanother instance using big.Float.SetString method
123.4 cannot be represented in binary with a finite number of bits.
--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/3t9ao7qtrlM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/721b9ad4-32f0-4aeb-93e6-4fe757174b5dn%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/e2fc093f-b730-4748-85d2-f85cdec6a29bn%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/e2bb6a46-02f0-4840-b147-c947f31a3ea8n%40googlegroups.com.