int i;
float *pf;
pf = (float *)&i;
*pf = 100.00;
printf("\n %d", i);
shanki himanshu 27 Light Poster
Recommended Answers
Jump to PostRun program and see
Jump to PostYou will get 100 if you change your printf() call as follows:
printf("\n%.0f", *pf);
The reason you are not getting 100 with your printf() call is essentially because computers represent floating point numbers and integers differently. The IEEE single-precision floating point format represents a floating point …
All 5 Replies
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
np complete 8 Newbie Poster
shanki himanshu 27 Light Poster
_avishek 29 For as long as space endures
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.