%a in printf

  • Thread starter karthikbalaguru
  • Start date
K

karthikbalaguru

Hi,

Kindly provide me with a link that talks in detail about the
reason for such an output with %a.

int main(void)
{
printf( "%a %a %a %a\n",3.14, 31.4, 0.0000314,0.14 );
return 0;
}

For the above program, i get the output as
0x1.91eb85p+1 0x1.f66666p+4 0x1.0766fcp-15 0x1.1eb852p-3

Any ideas ?

Thx in advans,
Karthik Balaguru
 
K

karthikbalaguru

Hi,

Kindly provide me with a link that talks in detail about the
reason for such an output with %a.

int main(void)
{
   printf( "%a %a %a %a\n",3.14, 31.4, 0.0000314,0.14 );
   return 0;

}

For the above program, i get the output as
0x1.91eb85p+1 0x1.f66666p+4 0x1.0766fcp-15 0x1.1eb852p-3

Any ideas ?

I also have the #include<stdio.h> at the top of the c file.

Karthik Balaguru
 
C

CBFalconer

Richard said:
karthikbalaguru said:


The behaviour of this program is undefined, for reasons you have
already been told about in a previous thread.

Assuming #include <stdio.h>, what is undefined? I have reread the
following a couple of times without a clue. Trial doesn't work,
since I don't have a C99 library.

a,A A double argument representing a floating-point |
number is converted in the style [-]0xh.hhhhp_d,
where there is one hexadecimal digit (which is
nonzero if the argument is a normalized floating-
point number and is otherwise unspecified) before
the decimal-point character221) and the number of
hexadecimal digits after it is equal to the
precision; if the precision is missing and FLT_RADIX
is a power of 2, then the precision is sufficient
for an exact representation of the value; if the
precision is missing and FLT_RADIX is not a power of
2, then the precision is sufficient to
distinguish222) values of type double, except that
trailing zeros may be omitted; if the precision is
zero and the # flag is not specified, no decimal-
point character appears. The letters abcdef are
used for a conversion and the letters ABCDEF for A
conversion. The A conversion specifier produces a
number with X and P instead of x and p. The
exponent always contains at least one digit, and
only as many more digits as necessary to represent
the decimal exponent of 2. If the value is zero,
the exponent is zero.

A double argument representing an infinity or NaN is
converted in the style of an f or F conversion
specifier.
 
R

Richard

Richard Heathfield said:
CBFalconer said:


What makes you think that assumption is valid?

<snip>

The fact that the OP said he did indeed include it.

At a guess.
 
C

CBFalconer

Richard said:
CBFalconer said:

What makes you think that assumption is valid?

Then what is your deep objection to saying so in your earlier
reply? Four words can avoid any misunderstanding. Instead you use
twelve to create a mystery. Usenet is not person to person, it is
person to public.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top