[go-nuts] Re: Inconsistent rounding with float printf ?

2019-12-06 Thread cratermoon
https://play.golang.org/p/j5HKxitS-Z6 See https://0.30004.com/ On Friday, December 6, 2019 at 1:25:01 AM UTC-8, Christophe Meessen wrote: > > I have noticed that printf performs an apparently inconsistent rounding of > floating point values. > > I divide a big number by 1000 and

Re: [go-nuts] Re: Inconsistent rounding with float printf ?

2019-12-06 Thread Jan Mercl
On Fri, Dec 6, 2019 at 6:04 PM Christophe Meessen wrote: > I can't change expectations. It is to convert a byte count into a human > readable byte count ( with kB, MB, ... units). So it was an XY problem? No floating point operations are necessary to do that. Also, check several existing

[go-nuts] Re: Inconsistent rounding with float printf ?

2019-12-06 Thread Christophe Meessen
I can't change expectations. It is to convert a byte count into a human readable byte count ( with kB, MB, ... units). I found out that I can produce the expected result by using math.Round. See here https://play.golang.org/p/UorDwbKlLj5 For my use case, I ended up converting "manually" the