lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] No manipulator for number of exponent digits?!


From: Vadim Zeitlin
Subject: Re: [lmi] No manipulator for number of exponent digits?!
Date: Thu, 21 Mar 2019 03:08:44 +0100

On Thu, 21 Mar 2019 01:57:45 +0000 Greg Chicares <address@hidden> wrote:

GC> Upgrading from gcc-7.x to -8.x, I see this regression in 'make system_test'
GC> results from a proprietary testdeck:
GC> 
GC> --8.33299753535067966748e-005
GC> +-8.33299753535067966748e-05

 The old format was compatible with the old MSVC CRT, while the new one is
compatible with the new one and is also standard-compliant, so in the grand
scheme of things, it's a good change.

GC> Obviously I should be able to add a manipulator in the implementation of
GC>   template<typename T> void SpewVector()
GC> to fix the number of exponent digits at three, as nature intends

 Standard is unnatural, of course, and so intends differently. I'm too lazy
to look it up myself, but a quick web search found the following quote[1]:

        "...The exponent always contains at least two digits, and only as
        many more digits as necessary to represent the exponent. ..."
        C11dr §7.21.6.1 8

GC> --but no, it can't be done, standardly, according to Kühl and Kanze...
GC> 
GC> 
https://stackoverflow.com/questions/9226400/portable-printing-of-exponent-of-a-double-to-c-iostreams/9226588#9226588
GC> 
GC> ...except with a custom num_put facet, which is too much work: we'll be
GC> better off just updating the stored system_test touchstone results when
GC> we upgrade the compiler. Still, it seems surprising that the number of
GC> exponent digits is left to the implementation's discretion, and that gcc
GC> (or MinGW-w64) has changed it.

 I don't know for sure why did they change it, but one possibility is that
the reason for using the old format was to be compatible with the system
compiler (MSVC) but as Microsoft has changed it to be standard-compliant a
couple of versions ago, there is no reason for gcc not to follow suit.

 Regards,
VZ

[1] 
https://stackoverflow.com/questions/31331723/how-to-control-the-number-of-exponent-digits-after-e-in-c-printf-e


reply via email to

[Prev in Thread] Current Thread [Next in Thread]