Topic: Number of digits for the exponent part in scientific format
Author: pjp@dinkumware.com ("P.J. Plauger")
Date: Wed, 4 Dec 2002 19:30:49 +0000 (UTC) Raw View
"KIM Seungbeom" <musiphil@bawi.org> wrote in message news:3DEDA7F4.5CCAD79E@bawi.org...
> [ Crossposted to: comp.std.{c,c++} ]
>
> Is there a way to set the number of digits for the exponent part
> in the floating-point scientific("%e") format?
>
> I was recently asked how, from someone saying that his program
> printed "1.000000+002" but he wanted "1.000000+02" instead.
>
> The C Standard says no more than that the exponent always contains
> at least two digits, and the C++ Standard seems to just rely on the
> C Standard about it.
C89 wasn't sufficiently clear on this topic, but C99 is quite clear that
three or more exponent digits should appear only if the leading digit is
nonzero. See our C library roundup at:
http://www.dinkumware.com/conform_c.html
for the implementations that still produce an extra digit.
I know of no way to control this behavior with the libraries that
don't conform.
P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: musiphil@bawi.org (KIM Seungbeom)
Date: Wed, 4 Dec 2002 16:51:00 +0000 (UTC) Raw View
[ Crossposted to: comp.std.{c,c++} ]
Is there a way to set the number of digits for the exponent part
in the floating-point scientific("%e") format?
I was recently asked how, from someone saying that his program
printed "1.000000+002" but he wanted "1.000000+02" instead.
The C Standard says no more than that the exponent always contains
at least two digits, and the C++ Standard seems to just rely on the
C Standard about it.
--
KIM Seungbeom <musiphil@bawi.org>
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]