(I did this by hand to confirm, he made me the big meany)
Excel, Libre Office, my calculator, Javascript, etc.. all get this number wrong. But with R there's a library that can add support for numbers this big. (I guess this is a well known issue)
Edit: _All_ numbers in JS are floating point numbers, there are no integers... <hmmm>
"In JavaScript, all numbers are implemented in double-precision [...] There is no specific type for integers."
> Handwaving is all I can do, I am just the tech taking orders.
Even "the tech" can have some understanding of finite precision integers and floats, and how they behave, given they're building blocks of the trade. It seems somewhat relevant to knowing what changes are valid to code. http://floating-point-gui.de/ is a great place to start if you're interested in learning more. :)
> Edit: _All_ numbers in JS are floating point numbers, there are no integers... <hmmm>
Not having any native integers is unfortunate and annoying, but there are various tricks to ensure numbers are integers (e.g. floats exactly represent integers up to 2^53) plus various tricks to convince the JS engines that things are guaranteed to be integers for optimizations. These are clunky and ugly hacks, but they're possible and even more possible when using JS as a compilation target from a different language (e.g. asm.js in the extreme).
> I guess this is a well known issue
Indeed, it very much is. As you demonstrate, even R doesn't allow doing your example calculation natively, you need to import a library... something that can be done just fine in JS too: for arbitrary size integers https://github.com/Yaffle/BigInteger and for arbitrary precision floats https://github.com/charto/bigfloat (among many examples). It's true that these won't approach the performance of GMP due to lack of access to the specialized instructions it uses, but they offer the same basic functionality.
That said, I agree with the general sentiment that JS is suboptimal for scientific computing, but mostly because of performance (although R's performance falls off very quickly when using anything other than vector operations) rather than inaccurate concerns about precision.
>Even "the tech" can have some understanding of finite precision integers and floats, and how they behave, given they're building blocks of the trade.
I do have "some understanding". But not enough to processing millions of records and notice that one or two numbers of output, out of hundreds, aren't correct. That's the PhD's job.
...apples and oranges....
R doesn't support non IEEE standard floats, what you are basically doing is using an external library (GMP), and special functions for addition, multiplication from that package.
Nor can any of the functions in R "base" use GMP.
Again, nobody is fudging numbers, neither R, Java, C, or JS because floating point is implemented on hardware so this argumument is a moot one.
Handwaving is all I can do, I am just the tech taking orders.
I just talked with my statistician friend on the phone, here's one issue my friend just showed me. (integer error, not even floating point)
111,111,111 * 111,111,111 = 12,345,678,987,654,321
(I did this by hand to confirm, he made me the big meany)
Excel, Libre Office, my calculator, Javascript, etc.. all get this number wrong. But with R there's a library that can add support for numbers this big. (I guess this is a well known issue)
Edit: _All_ numbers in JS are floating point numbers, there are no integers... <hmmm>
"In JavaScript, all numbers are implemented in double-precision [...] There is no specific type for integers."
Edit 2: (for fun) This is from R:
[0] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guid...