Sunday, December 4, 2011

What is the actual compiler method to change a floating type variable into binary form...?

suppose i've a program





float a=3.14;


then what will be the actual value stored in memory in binary form n what will be the procedure used by compiler...........?





thanks in advance|||For floating point represenations: http://en.wikipedia.org/wiki/Floating_po鈥?/a>


How the compiler goes about storing that is a pretty advanced topic since compiler engineering is pretty complex. I would recommend picking up "Engineering a Compiler" or the Dragon Book (a simple Google or Amazon search brings it right up) if you want to understand how compilers go about storing floating point numbers in variables.|||I dont know why that guy is calling it advanced or complex or whatever. Its actually really simple. The algorithm for storing floating point numbers is defined by IEEE-754.





3.14 as a 32bit float would be stored as 4048F5C3 in memory.








http://en.wikipedia.org/wiki/IEEE_754-20鈥?/a>

No comments:

Post a Comment