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.

---
Santhosh

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 function
>>     another instance using big.Float.SetString method
>>
>> when compared both these instances using big.Float.Cmp, it return non-zero
>>
>> code: https://play.golang.org/p/NhQ-klcph2z
>>
>> am I doing something wrong ?
>> can some one explain why Cmp returns non-zero ?
>>
>> thanks
>> Santhosh
>>
>>
>> -- 
>> 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
>>  
>> <https://groups.google.com/d/msgid/golang-nuts/82e16a17-387e-41cb-a79c-723c2e8a772bn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> -- 
> Kurtis Rader
> Caretaker of the exceptional canines Junior and Hank
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/62f0afbd-31d3-42db-b967-9a6b5b77d838n%40googlegroups.com.

Reply via email to