|
From: Keith M. <kei...@us...> - 2008-12-17 17:56:36
|
On Wednesday 17 December 2008 02:50:42 Sisyphus wrote:
> On linux and cygwin, printf("%e", -1.25) outputs 1.250000+00.
> On windows it outputs 1.250000+000. (There's an extra '0' at the
> end).
That's correct. ISO C99 and POSIX both require *a* *minimum* of two
exponent digits. Linux and Cygwin aim to conform to POSIX, hence two
digits is what they use. OTOH, MinGW strives for conformance with
the MS-Windows standards, as documented on MSDN; these stipulate a
minimum of *three* exponent digits.
> Compiling on windows with the '-ansi' switch makes no difference.
Well no, it doesn't, because providing three digits, as required by
the MSW standard, doesn't violate the ISO C99 requirement of no less
than two; (three is not less than two). Of course, it isn't entirely
compliant with the ISO C99 stipulation that, subject to there being
at least two digits, there shall be no more than are necessary to
represent the required exponent value. However, we comply with the
MSDN standard, requiring at least three digits, because that is what
is most applicable on our host platform of (maybe reluctant) choice,
and is therefore best aligned with our minimalist objective, which is
to provide a free compiler suite for the *native* MSW platform.
> Because of this error in the windows runtime, 3 tests in the
> mpfr-2.4.0-rc1 test suite fail.
It *isn't* an error in the MSW runtime; MPFR should be cognisant of
the standards which prevail, on the host platform for which it is
being deployed -- those three tests should be rewritten, to accept
whatever minimum number of exponent digits is standard for the host.
> Can this aspect of the "%e" formatting be fixed in a future release
> of MinGW ?
It isn't broken, so there is nothing for us to fix. In a follow up
post, Gisle Vanem said:
> How about you fix it yourself? If at all it should be fixed.
See above; there is nothing to fix. However, if you link with MSVCR80
or later, *you* can call Microsoft's _set_output_format() function,
to select _TWO_DIGIT_EXPONENT mode for subsequent printf() formatted
output; if you use mingwrt-3.15 or later, you can add
PRINTF_EXPONENT_DIGITS=2
to your (exported) environment, and compile with `-ansi' or `-posix',
to achieve the same effect, with *any* MinGW supported version of
MSVCRT. (An RTFM is probably warranted here; see the release notes
for mingwrt-3.15, at http://tinyurl.com/6h6bbc).
GV went on to ask:
> Who says linux and cygwin is correct in this respect?
To which Rob [Sisyphus] replied:
> The mpfr developers are of the view that linux and cygwin is
> correct - and that windows is failing to comply with ansi standards.
So what? Since when have Gates, Ballmer and cohorts ever complied
with *any* recognised standards but their own? For better, or for
worse, ANSI is largely irrelevant on MS-Windows; the only "standard"
which is applicable is what is documented on MSDN.
> Those guys are usually pretty switched on when it comes to ansi
> standards.
And indeed, when talking about a POSIX or ANSI compliant host, they
are correct on this point. However, in the case of *native* MSW...
> Are they wrong on this occasion ?
With all due respect to the MPFR developers, yes, they are dead wrong
on this occasion; when targetting an MSW host, neither ANSI nor POSIX
necessarily applies, and if they insist that those standards must be
honoured, then I fear that they may have completely lost the plot.
> If so, I'm certainly willing to take them to task over the matter.
Please do.
--
Regards,
Keith.
|