Re: [go-nuts] Re: keep just 2 decimal places in a float64

2020-02-02 Thread Jason E. Aten
Thanks Michael! > > -- 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

Re: [go-nuts] Re: keep just 2 decimal places in a float64

2020-02-01 Thread Michael Jones
forgot the code...final test is what generates the report above. float128.go: https://play.golang.org/p/2MzjllLC3qT float128_test.go: https://play.golang.org/p/ZQwsFh0_Apt On Sat, Feb 1, 2020 at 7:32 PM Michael Jones wrote: > As promised, some careful results from one of the tests in my >

Re: [go-nuts] Re: keep just 2 decimal places in a float64

2020-02-01 Thread Michael Jones
As promised, some careful results from one of the tests in my doubled-precision library. Rows are iteration's of Jean-Michel Muller's roundoff-intolerant Œ() function: http://perso.ens-lyon.fr/jean-michel.muller/ Columns are 32-bit floating point,64-bit floating point, my fast 128-bit library,

Re: [go-nuts] Re: keep just 2 decimal places in a float64

2020-02-01 Thread Jason E. Aten
I appreciate the sophisticated and math conscious discussion here. For those reading this thread in the future, I note the state of the art in Go at the moment seems to be this arbitrary precision decimal library created by the CockroachDB guys for APD standard/postgresql conformance. Note that

Re: [go-nuts] Re: keep just 2 decimal places in a float64

2020-02-01 Thread Michael Jones
Your expectations are wrong in the sense of being overly optimistic. This is a chaotic attractor, under any form of rounding or precision it will “fail” in the way you mean (and “succeed” in proving the power of a strong attractor!) I have this as a test at home that does each step in 32, 64,

Re: [go-nuts] Re: keep just 2 decimal places in a float64

2020-02-01 Thread Manlio Perillo
Even if fixed supports 7 decimal places, those 7 decimal places should have the same value (after rounding) as the result provided by math.Big. I suspect the precision loss is in the Div method: https://github.com/robaho/fixed/blob/master/fixed.go#L232 Manlio Perillo On Sunday, February 2,

Re: [go-nuts] Re: keep just 2 decimal places in a float64

2020-02-01 Thread Robert Engels
fixed only supports 8 decimals places - fixed. Without digging into the algorithm I’m sure that is the source of your issue. > On Feb 1, 2020, at 4:03 PM, craterm...@gmail.com wrote: > >  > Perhaps I'm doing something wrong or using the library outside of its > intended purpose, but I found

Re: [go-nuts] Re: keep just 2 decimal places in a float64

2020-02-01 Thread cratermoon
Perhaps I'm doing something wrong or using the library outside of its intended purpose, but I found that this library doesn't handle Muller's Recurrence correctly. For those not familiar, Muller's Recurrence is 108 - (815-1500/z)/y https://play.golang.org/p/sePTgjZzHeY See

Re: [go-nuts] Re: keep just 2 decimal places in a float64

2020-01-26 Thread Robert Engels
Which is exactly what github.com/robaho/fixed and many others do! > On Jan 26, 2020, at 10:34 AM, Michael Jones wrote: > >  > ...thus the virtue of scaled integers. scaling by 100 makes cents whole, > scaling by 1*100 gives four decimal places beyond that. There is nothing > bad about

Re: [go-nuts] Re: keep just 2 decimal places in a float64

2020-01-26 Thread Michael Jones
...thus the virtue of scaled integers. scaling by 100 makes cents whole, scaling by 1*100 gives four decimal places beyond that. There is nothing bad about floating point despite the reputation, it's just not the number system from algebra; nor is binary floating point the same as decimal

Re: [go-nuts] Re: keep just 2 decimal places in a float64

2020-01-26 Thread 温博格
And from Wikipedia on the Vancouver Stock Exchange. "The history of the exchange's index provides a standard case example of large errors arising from seemingly innocuous floating point calculations. In January 1982 the index was initialized at 1000

Re: [go-nuts] Re: keep just 2 decimal places in a float64

2020-01-26 Thread Robert Engels
Just an FYI, often that is not correct. Many financial systems require fractional pennies due to the volume of transactions. Think about taxing stock exchanges the pennies add up quickly at any tax rate, so they use fractional pennies to reduce the size of the error bucket. > On Jan 26,

[go-nuts] Re: keep just 2 decimal places in a float64

2020-01-26 Thread Pat Farrell
never use floating point if you are trying to represent money, say dollars and cents or decimal values of the euro. Store the money as integer number of pennies. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and

Re: [go-nuts] Re: keep just 2 decimal places in a float64

2020-01-25 Thread Kurtis Rader
On Sat, Jan 25, 2020 at 9:26 PM wrote: > Floating point math has many pitfalls. > https://play.golang.org/p/LK0lla8hM9w See also > https://0.30004.com/ > I was not aware of URL https://0.30004.com/. Like the XY problem URL, http://xyproblem.info/, the URL you cited is

[go-nuts] Re: keep just 2 decimal places in a float64

2020-01-25 Thread cratermoon
Floating point math has many pitfalls. https://play.golang.org/p/LK0lla8hM9w See also https://0.30004.com/ s On Saturday, January 25, 2020 at 7:14:15 PM UTC-8, Jason E. Aten wrote: > > > https://play.golang.org/p/87bDubJxjHO > > I'd like to truncate a float64 to just 2 decimal