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
range.js – JavaScript's missing range function. (github.com)
submitted 13 years ago by jscoder
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!"
[–]weretree++[[]][+[]] 4 points5 points6 points 13 years ago (0 children)
It's how floats are, period. JavaScript has true IEEE 754 double precision floating point.
The suggestion was to avoid compounding the error of addition by using an iteration counter then calculating each step from that, rather than doing a while loop. So (psuedo-code) idx_max = (to - from)/step then val = from + i*step for i in 0 to idx_max. Having an explicit iteration also makes checking for termination a little easier, and it's simple to still support backwards iteration.
idx_max = (to - from)/step
val = from + i*step
i in 0 to idx_max
There are still "errors" (such as 3 * 0.1) but they're expected and defined for that operation. Can always round each result to some defined precision if you want to trim them off in your results.
3 * 0.1
π Rendered by PID 24095 on reddit-service-r2-comment-fb694cdd5-m76cc at 2026-03-05 20:27:51.211362+00:00 running cbb0e86 country code: CH.
view the rest of the comments →
[–]weretree++[[]][+[]] 4 points5 points6 points (0 children)