While Reals are known to be unprecise, they are 100% accurate even for very large numbers, as long as they do not use a decimal point (=integers).
Numbers up to 53 bit, or more exactly, [-(2^53)+1, (2^53)-1], that is a range from −9,007,199,254,740,992 to 9,007,199,254,740,992, will be exactly represented.
More about Reals
If you look at the definition of Double-precision binary floating-point on Wikipedia, this is what you’ll find about the splitting and precision of the digits:
“The 53-bit significand precision gives from 15 to 17 significant decimal digits precision (2−53 ≈ 1.11 × 10−16). If a decimal string with at most 15 significant digits is converted to IEEE 754 double-precision representation and then converted back to a decimal string with the same number of digits, the final result should match the original string. If an IEEE 754 double-precision number is converted to a decimal string with at least 17 significant digits, and then converted back to double-precision representation, the final result must match the original number.”
Convert to string
While it was possible to do calculations on large numbers with the Real type for many years, converting to or from the text was limited to using 12-digit scientific notation, resulting in losing precision.
With 4D v19 R6, we have improved the accuracy and the conversion of a Real number (presenting an integer) into a Text.
The improvement of the conversion to string concerns the String() command and the JSON and XML commands returning numbers in string form.
Code Editor
For example, you can now type in the code editor:
$r:=2147483647000000
and it will stay as-is instead of being formatted as:
$r:=2.147483647e+15
Happy coding!