# print f %E (6.1)

According to the doc, for E format, an exponent sign and a 3 digits
number are always produced.
According to my tests, only a 2 digits number is written.

What’s wrong?

Alain.

According to my test, it can be 1, 2 or 3 digits, depends on circumstances

printf_test.c={
//////////////////////////
#include <stdio.h>
int main (void){
double bigvalue=0.0000004354667e128;
double value=3.1415628;
printf("\n my bigvalue is %E \n my value is %e \n" , bigvalue, value);
return 0;
}
////////////////////////}

\$ gcc printf_test.c
\$ ./a.out

## my bigvalue is 4.354667E+121 my value is 3.141563e+0 \$

Eduard.
ed1k at ukr dot net

Alain Bonnefoy <alain.bonnefoy@icbt.com> wrote in article <3D37F9A1.2070403@icbt.com>…

According to the doc, for E format, an exponent sign and a 3 digits
number are always produced.
According to my tests, only a 2 digits number is written.

What’s wrong?

Alain.

ed1k <ed1k@spamerstrap.com> wrote:
: According to my test, it can be 1, 2 or 3 digits, depends on circumstances

POSIX says that there should be at least two digits in the exponent. I’ll
fix the docs.

## Steve Reid stever@qnx.com TechPubs (Technical Publications) QNX Software Systems

Steve Reid <stever@qnx.com> wrote:
: ed1k <ed1k@spamerstrap.com> wrote:
: : According to my test, it can be 1, 2 or 3 digits, depends on circumstances

: POSIX says that there should be at least two digits in the exponent. I’ll
: fix the docs.

I tried some examples, and found that the exponent is one digit long only
if the exponent is 0.

Here’s what ANSI says:

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.

That last sentence could be clearer (do they mean that the exponent is 0 or
00?), but I think the first sentence decrees that an exponent of 0 should be
printed as 00.

At any rate, the docs are now more correct than they were.

## Steve Reid stever@qnx.com TechPubs (Technical Publications) QNX Software Systems

Steve Reid <stever@qnx.com> wrote in article <ah976m\$faj\$1@nntp.qnx.com>…

Steve Reid <> stever@qnx.com> > wrote:
: ed1k <> ed1k@spamerstrap.com> > wrote:
: : According to my test, it can be 1, 2 or 3 digits, depends on circumstances >

: POSIX says that there should be at least two digits in the exponent. I’ll
: fix the docs.

I tried some examples, and found that the exponent is one digit long only
if the exponent is 0.

Oops, sorry I did not include example for two digit in my printf_test.c beccause it was mentioned
by Alain Yes, you’re right.

Here’s what ANSI says:

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.

I think in QNX 6.1 it’s implemented as ANSI says. Just documentation in 6.1 is not very clear.

That last sentence could be clearer (do they mean that the exponent is 0 or
00?), but I think the first sentence decrees that an exponent of 0 should be
printed as 00.

Since POSIX says “two digit” then should be e00 But from ANSI I understand that e0 is good also
but, may be, it is only for 0.000000e0???

At any rate, the docs are now more correct than they were. >

Have to install 6.2 and see

## Cheers,

Eduard.
ed1k at ukr dot net

## Steve Reid > stever@qnx.com TechPubs (Technical Publications) QNX Software Systems

Steve Reid <stever@qnx.com> wrote:

Here’s what ANSI says:

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.

That last sentence could be clearer (do they mean that the exponent is 0 or
00?), but I think the first sentence decrees that an exponent of 0 should be
printed as 00.

I think it’s pretty clear for the C Standard. It doesn’t say “the
exponent is one digit zero”, does it?

The purpose of that last sentence is not to make an exception to the
previous sentence – it is to say that things like “0.0E128” or “0e-77”
are not acceptable.

Wojtek Lerch QNX Software Systems Ltd.

Wojtek Lerch <wojtek_l@yahoo.ca> wrote:
: I think it’s pretty clear for the C Standard. It doesn’t say “the
: exponent is one digit zero”, does it?

No, it doesn’t. Too bad that that’s what printf() produces.