News for hackers. Stuff that matters.
Re:0.30000000000000004 by imjustsaying on Sunday April 02, 2017 @03:26PM (#14018538)
Why does PHP produce 0.3 instead?

edit: Not sure how I missed that. Thanks!

Re:0.30000000000000004 by noonespecial on Sunday April 02, 2017 @03:31PM (#14018577)
Third example in the article:

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 by arkitaip on Sunday April 02, 2017 @03:31PM (#14018572)
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).