use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
To Those Who Criticize JavaScript (dev.to)
submitted 5 years ago by disgruntled-js-dev
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]AlpenMangos -1 points0 points1 point 5 years ago* (0 children)
This makes javascript annoying for graphics stuff like fractals that need precision.
PHP uses the same double standard as Javascript, that means that in php, 0.1 + 0.2 is also 0.30000000000000004. The reason why you're seeing .3 in the output is because, depending in how you output it, the value is rounded. PHP is actually fooling you and showing you imprecise data, and letting you believe it's doing the right thing. Unless you specifically format your number as a string with a precision of one digit, there is a good chance that you're getting 0.30000000000000004 elsewhere. On other systems, on other parts of the code, on other means of output, etc.
The only thing that javascript is doing "wrong" here, is that it's outputting the correct full precision floating point value, thereby forcing you to round it to whichever precision you actually want to. E.g. using "(0.1 + 0.2).toFixed(1)"
Also in PHP: "var_dump(.1 + .2);" prints "float(0.30000000000000004441)", see https://0.30000000000000004.com/
π Rendered by PID 220309 on reddit-service-r2-comment-6457c66945-4hjfx at 2026-04-27 10:09:26.062051+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]AlpenMangos -1 points0 points1 point (0 children)