+ 21

Why JS use double precision floating point numbers???

Just started with JS....nd it's interesting...so I really don't want to keep any doubt in my mind

2nd Jun 2017, 6:43 AM
Torpid
Torpid - avatar
3 ответов
2nd Jun 2017, 7:28 AM
Dev
Dev - avatar
+ 7
"Why". It looks like BigNums weren't ready, "because Microsoft is coming for you", and they had to "write JS in 10 days". Those floats appear in ECMAScript version 1 (what JS is based on), where Numbers are IEEE-754 floats. Reference....rant + comments: "[You would think] any sane language runtime would have integers transparently degrade to BIGNUMs...[[sarcasm] for JavaScript dodging the MAXINT problem]..." https://www.jwz.org/blog/2010/10/every-day-i-learn-something-new-and-stupid/ The author seems to indicate 32-64bit transition was hard for new graduates (so just throw floats at it)...and commentors write that Mozilla + IBM pushed because Microsoft had just undervalued Netscape...and Microsoft (who had ECMAScript as JScript) was coming after Mozilla...giving just 10 days to write JS and make it look like Java (actually C). Historical "ES" releases: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Language_Resources Currently: SoloLearn seems to use ECMAScript from Android WebView (that's Google Chrom...ium). I see mostly version 5 (ES5) support here, some ES6 (2015). "Typed arrays" / dataviews support integers but you have to use them on purpose. Something I wrote to "look inside" floats...where I use some of the special "int" functions ( like getUint8 ): https://code.sololearn.com/WYCTOysAGnLv/?ref=app
4th Jun 2017, 7:12 PM
Kirk Schafer
Kirk Schafer - avatar
+ 5
JS was made to process information and return to user or/and the browser, most of this information was to calculate something, so the precision was required. I hope I have helped
2nd Jun 2017, 7:26 AM
Juliano Ventola
Juliano Ventola - avatar