PDA

View Full Version : [SOLVED] how float variable store in memory



srikanth2
February 10th, 2014, 03:17 PM
In GDB how to find float variable storage in memory ..
and i want how float value converting into binary form .. can any one explain this ..!!!!!


Thanks you ---

Bachstelze
February 10th, 2014, 04:29 PM
There is no special storage area in memory for floating-point variables, they are stored in exactly the same way as any other variable.

srikanth2
February 10th, 2014, 04:46 PM
or can know how the float point variable into binary number ..???

Dave_L
February 10th, 2014, 05:04 PM
Does this help?
http://students.byu.edu/~cs124ta/references/readings/floating%20point%20numbers.html

srikanth2
February 10th, 2014, 05:33 PM
Thank You Dave_L ... But i need an example with explaination .... :

MadCow108
February 10th, 2014, 07:18 PM
the wiki articles describes the common representation:
http://en.wikipedia.org/wiki/Floating_point

but how exactly its done depends on the platform, there are plenty variations.

with gdb you can print it by reinterpreting it as an integers of equal size:

p *(int64_t*)(address-of-double)
p *(int32_t*)(address-of-float)