When I ask GDB to print the real one in binary, I get the following:
(gdb) p/t 5210887.5
$1 = 10011111000001100000111
According to this ,
0 10010101 00111110000011000001111
- expected value.
Alignment
1 0011111000001100000111
0 10010101 00111110000011000001111
And it looks like GDB gives me an integer representation after rounding. The fact is that this was done with a variable at work. Using an ad in program C -
main()
{
float f = 5210887.5;
}
and debug it -
$ gcc -g -O0 floatdec.c -o floatdec
$ gdb floatdec
GNU gdb (GDB) Red Hat Enterprise Linux (7.2-60.el6_4.1)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/ /floatdec...done.
(gdb) b main
Breakpoint 1 at 0x804839a: file floatdec.c, line 3.
(gdb) r
Starting program: /home/ /floatdec
Breakpoint 1, main () at floatdec.c:3
3 float f = 5210887.5;
(gdb) s
4 }
(gdb) p f
$1 = 5210887.5
(gdb) p/t f
$2 = 10011111000001100000111
same thing, it shows me an integer representation. Isn't there a way to show gdb floating point format?
source
share