4 ms·
Does this mean I could write a calculator in JavaScript which is more accurate than the language but not as fast? For example: just treat numbers as strings an
by arduinomancer 6y ago
Does this mean I could write a calculator in JavaScript which is more accurate than the language but not as fast?
For example: just treat numbers as strings and write code that adds the digits one by one and does the right carries
Now that I think about it, is this the whole point of the Java BigDecimal class?
- jeffbee 6y agoYes, and it would be inexcusable malpractice to implement a calculator using the native floating-point type.
- spicybright 6y agolol, malpractice. What if you want a calculator that specifically uses native floating point math, like to aid in programming, or just playing with the datatype?
- dsego 6y agoIt's been done, there are libraries out there.
- teachingassist 6y agoYou can likely do better than this within rational numbers by working with integer numerator and denominator; you'll still have to make compromises for irrational numbers.