0.30000000000000004
11–20 of 140 posts
Re: 0.30000000000000004
#12Why does PHP produce 0.3 instead? edit: Not sure how I missed that. Thanks!
PHP converts 0.30000000000000004 to a string and shortens it to "0.3". To achieve the desired floating point result, adjust the precision ini setting: ini_set("precision", 17).
I remember years ago learning something like this and coming to a horrible realization : "My god, they're all strings!"
Re: 0.30000000000000004
#13Re: 0.30000000000000004
#14Rexx has decimal arithmetics so 0.1+0.2 is 0.3 ... http://www.rexxla.org/events/2001/mike/rexxsy01.PDF
Re: 0.30000000000000004
#15Previous discussions: https://news.ycombinator.com/item?id=10558871 (1.5 years ago, 240 comments) https://news.ycombinator.com/item?id=1846926 (6.5 years ago, 128 comments)
Someone should figure out the mean length of time between article repeats on HN. And then find some correlation with university degrees and job tenure.
Re: 0.30000000000000004
#16Any time you're generating percentage data that should sum to 100, not appreciating floating point math will burn you. For those interested, the largest remainder method ( https://gist.github.com/hijonathan/e597addcc327c9bd017c ) is useful for dealing with this.
Re: 0.30000000000000004
#17Previous discussions: https://news.ycombinator.com/item?id=10558871 (1.5 years ago, 240 comments) https://news.ycombinator.com/item?id=1846926 (6.5 years ago, 128 comments)
Re: 0.30000000000000004
#18I'm not sure this is such a good idea. I love rational datatype, but it's too easy to shoot yourself in the foot with simple numerical procedures resulting in gigantic bignum denominators.
Re: 0.30000000000000004
#19Whats going on in the second D example?
Re: 0.30000000000000004
#20In a way, not so simple (obvious to you? not to me)