/* Note: This e-mail is a program too. So, you can try it.
Hi Rexx community,
As we can read in manuals of the Rexx language (for example in
AS/400 REXX/400 Reference; SC41-5729-00; chapter 6; 6.2.7
Exponential notation):
"If the number of places needed before the decimal point exceeds
DIGITS, or the number of places after the point exceeds twice DIGITS,
exponential form will be used."
It is not exactly true as shown in a following example:
*/
numeric digits 4
say "12345 + 0 ->" 12345 + 0
say "0.123456789 + 0 ->" 0.123456789 + 0
say "0.00000123 + 0 ->" 0.00000123 + 0
say "0.000001234 + 0 ->" 0.000001234 + 0
say "0.0000123456789 + 0 ->" 0.0000123456789 + 0
say "0.0000012345678 + 0 ->" 0.0000012345678 + 0
say "0.00001234567890123456789 + 0 ->",
0.00001234567890123456789 + 0
/* Results are:
12345 + 0 -> 1.235E+4
0.123456789 + 0 -> 0.1235
0.00000123 + 0 -> 0.00000123
0.000001234 + 0 -> 1.234E-6
0.0000123456789 + 0 -> 0.00001235
0.0000012345678 + 0 -> 1.235E-6
0.00001234567890123456789 + 0 -> 0.00001235
Therefore I advice you to think of this theorem:
"If the number of places needed before the decimal point exceeds DIGITS, or the number leading zeros after the point exceeds DIGITS and number of places after the point exceeds twice DIGITS, exponential form will be used."
Do you agree?
*/
In article
Exponential notation
Vladimir Zabrodsky would have us change the rules for exponential notation
from:
"If the number of places needed before the decimal point exceeds DIGITS,
or the number of places after the point exceeds twice DIGITS, exponential
form will be used."
to:
"If the number of places needed before the decimal point exceeds
DIGITS, or the number leading zeros after the point exceeds DIGITS
and number of places after the point exceeds twice DIGITS,
exponential form will be used."
There is no difference between these two statements. When you say:
0.00001234567890123456789 + 0
the first thing Rexx will do is chop off all those unnecessary digits,
leaving you with 0.00001235 (since numeric digits is 4). The second thing
it will do is use the above rule to determine whether to write the result
in exponential notation. There are only eight digits after the decimal
point, so exponential notation is not used.
Once the number has been rounded there can be at most DIGITS non-zero
digits after the decimal point, so the first statement above implies
the second. That is, if the number of places after the point exceeds
twice DIGITS then at least DIGITS+1 of them must be zeros.
|