>>>> "APA" == Adrian Aichner
<Adrian.Aichner(a)t-online.de> writes:
APA> These test fails because my system prints 3 digits for the exponent:
APA> (format "%e" 100)
APA> "1.000000e+002"
APA> MSDN actually documents that exponents are always printed with three
APA> digits.
APA> What's the preferable way to fix these tests?
APA> 1.
APA> (cond
APA> ((equal system-type 'windows-nt)
APA> (Assert (string= (format "%e" 100) "1.000000e+002")))
APA> (t
APA> (Assert (string= (format "%e" 100) "1.000000e+02"))))
APA> 2.
APA> (Assert (string-match "1\\.000000e\\+0?02" (format "%e" 100)
0))
I vote for 2. Except that the 3rd arg to string-match seems unnecessary.
(Assert (string-match "1\\.000000e\\+0?02" (format "%e" 100)))
Of course, a comment should be added.
Microsoft's implementation is not standard compliant. From the standard:
e,E A double argument representing a floating-point
number is converted in the style [-]d.ddde_dd, where
there is one digit before the decimal-point
character (which is nonzero if the argument is
nonzero) and the number of digits after it is equal
to the precision; if the precision is missing, it is
taken as 6; if the precision is zero and the # flag
is not specified, no decimal-point character
appears. The value is rounded to the appropriate
number of digits. The E conversion specifier will
produce a number with E instead of e introducing the
=====> exponent. The exponent always contains at least two
=====> digits, and only as many more digits as necessary to
represent the exponent. If the value is zero, the
exponent is zero.
A double argument representing an infinity or a NaN
is converted in the style of an f or F conversion
specifier.
So the truly correct thing to do is for (format) to remove the extra
zero digit, but only on Microsoft platforms. Probably not worth it.