0.30000000000000004
0.30000000000000004.com
0.30000000000000004
1–10 of 140 posts
Re: 0.30000000000000004
#2That "digits=18" in R example probably bothers me more than it should.
Re: 0.30000000000000004
#3Why does PHP produce 0.3 instead?
edit: Not sure how I missed that. Thanks!
Re: 0.30000000000000004
#4Previous 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
#5The C++ code could use std::numeric_limits:: max_digits10 instead of the magical 17!
Re: 0.30000000000000004
#6Rexx has decimal arithmetics so 0.1+0.2 is 0.3 ...
Re: 0.30000000000000004
#7Any 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
#8The C++ code could use std::numeric_limits :: max_digits10 instead of the magical 17!
That reads like the code equivalent of involuntarily burping in polite company.
Re: 0.30000000000000004
#9Previous 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
#10Why 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).