This can done using a good debugger and a simple sample program. We’ll use the program in listing 1 as an example to find out the bit pattern of 0.2 as a single precision floating point number.
We compile the program using the command gcc -g -o test test.c to make sure the debug symbol table remains intact. Next, we invoke the debugger using the command gdb test. Once we enter the debugger, we use the command b 6 to insert a breakpoint on line 6.
Then, we use the command run in gdb to run the program. The programs stops on line 6. Here, we can examine the value of variable f as a 32-bit binary number using the commmand x/tw &f to examine the variable in binary.
We should see exactly the same bit pattern as table 3.