I am debugging a C++ application and when I display a double-precision floating point number in GDB I get a result like:.035449094393
How do I display more decimal places? Ideally I would be able to specificy the precision and get a result like: .0354490943927692
Basically, I am attempting to find the reason for a very minor difference between 2 variables. If I use printf with a format specifier like %1.20f
I can see the difference in the variables but not using GDB.
By default, GDB's p/f <variable>
has limited precision.
You can use printf
to show more decimal places:
(gdb) printf "%1.20f\n", <variable>
However, it is very likely that at this point you will start running into the limitations of your data type (there may be rounding errors and other small deviations from what you might expect as a value).
You can do call printf("%.10f\n", d)
in gdb
and it will print it in stdout
with the desired format.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With