printf("%d",float)
- From: candy_init@xxxxxxxxx
- Date: 30 Oct 2007 17:48:57 -0700
Hi all,
I just came across the following program:
#include <stdio.h>
int main()
{
float a = 12.5;
printf("%d\n", a);
printf("%d\n", *(int *)&a);
return 0;
}
The program prints 0 and 1095237362. However, in my opinion it should
print 12 at both the places. Can anybody tell me where I am wrong?
.
- Follow-Ups:
- Re: printf("%d",float)
- From: Ernie Wright
- Re: printf("%d",float)
- From: Philip Potter
- Re: printf("%d",float)
- From: ming li
- Re: printf("%d",float)
- From: andreyvul
- Re: printf("%d",float)
- From: santosh
- Re: printf("%d",float)
- From: Richard Heathfield
- Re: printf("%d",float)
- Prev by Date: Re: Bug/Gross InEfficiency in HeathField's fgetline program
- Next by Date: Macro that expand differently depending on the function calling it.
- Previous by thread: Re: Void function returns value
- Next by thread: Re: printf("%d",float)
- Index(es):
Relevant Pages
|