Re: printf("%d",float)
- From: Richard Heathfield <rjh@xxxxxxxxxxxxxxx>
- Date: Wed, 31 Oct 2007 06:51:52 +0000
Jack Klein said:
On Wed, 31 Oct 2007 01:15:33 +0000, Richard Heathfield<snip>
<rjh@xxxxxxxxxxxxxxx> wrote in comp.lang.c:
You are wrong in thinking that %d is the appropriate format specifier
for a float, and you are wrong in thinking that you can meaningfully
cast the address of a float into the address of an int.
You were right in the first pronouncement, not necessarily so in the
second. The result of casting a pointer to an object or incomplete to
a pointer to any other object or incomplete type, is undefined if the
pointer is not suitably aligned for the second type, but well defined
if there is no alignment error. Of course, dereferencing that pointer
is completely undefined.
Right, which is why I consider the conversion meaningless.
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
.
- Follow-Ups:
- Re: printf("%d",float)
- From: Philip Potter
- Re: printf("%d",float)
- References:
- printf("%d",float)
- From: candy_init
- Re: printf("%d",float)
- From: Richard Heathfield
- Re: printf("%d",float)
- From: Jack Klein
- printf("%d",float)
- Prev by Date: Re: make on multiple platforms
- Next by Date: ***********C Langu*****
- Previous by thread: Re: printf("%d",float)
- Next by thread: Re: printf("%d",float)
- Index(es):
Relevant Pages
|