Fellow Blocklanders - as you no doubt know, all numbers have a maximum precision of six decimal digits. All attempts to calculate values beyond this cosmic limit are doomed to failure. This is the basis of all mathematics, and we have based our entire society on this well-known maximum limit.
Some fools have
dared to go beyond this limit, but they were derisively dismissed as lunatics with no regard for the natural order of things.
But it is all a lie! The underlying fabric of reality we all live within allows a maximum of
up to sixteen decimal digits of precision! Our entire knowledge of mathematics is a baseless lie! We have been following arbitrary limits imposed by an unseen force!
All jokes aside, TorqueScript implements
double-precision floating-point mathematics in the underlying engine code; the full precision is simply truncated to six decimal digits when converting to a string or crossing function calls. Try the following code snippets in the console - the "Expected Result (6 digits)" is what we'd expect to get if the numbers were truncated to 6 digits before being passed into mathematical operands.
Code Example | Expected Result (6 digits) | Expected Result (Single) | Expected Result (Double) |
echo((1+mPow(2,-23))-1); | 0 | 1.19209289...*10-7 | 1.19209289...*10-7 |
echo((1+mPow(2,-52))-1); | 0 | 0 | 2.22044604...*10-16 |
echo(mPow(2,1023)); | 8.98847e+307 | Positive Infinity | 8.98846567...*10307 |
echo(mPow(2,127)+mPow(2,125)); | 2.12676e+38 | 2.12676479...*1038 | 2.12676479...*1038 |
echo((mPow(2,127)+mPow(2,125))-2.12676e+38); | 0 | 4.867778...*1032 | 4.79325586...*1032 |
echo(1/3-0.333333); //Ipqµarx | 0 | 3.476938...*10-7 | 3.33333333...*10-7 |
So now the only question remaining is how to utilize the full precision of the underlying doubles without being truncated to six decimal digits.