Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

%a correctly rounded to specified precision

0 views
Skip to first unread message

kyuupi

unread,
Jul 3, 2009, 10:31:38 AM7/3/09
to
Given an IEEE 754 double implementation,

#include <float.h>
#include <stdio.h>

int main (void)
{
printf ("%.2a\n", DBL_MAX);
return 0;
}

the correctly rounded value of DBL_MAX the given precision, whilst
still being representable as a double, is +infinity in round-to-
nearest mode.

Is the intent of the standard that in this case text like "inf" (etc)
be output, or that an unrepresentable value like

0x2.00p+1023

be output? Most C libraries I have tried output the latter.

Vincent Lefevre

unread,
Jul 3, 2009, 12:46:32 PM7/3/09
to
In article <bbea7062-210d-4eb8...@a37g2000prf.googlegroups.com>,
kyuupi <kyuup...@gmail.com> wrote:

> #include <float.h>
> #include <stdio.h>

> 0x2.00p+1023

I think this is the only correct output, as string representations
don't have a limited exponent range (0x2.00p+1023 is representable
as a string). This is consistent with what you would get with %e
and %f.

--
Vincent Lef�vre <vin...@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)

0 new messages