Possible duplicate:
Why does gdb evaluate sqrt (3) to 0?
C newbie here. There should be an obvious explanation of why gdb gives strange outputs when trying to use the math.h functions in a string. For example, the fabs
function below should take an absolute value and return double.
(gdb) p cos(2*3.141/4) $13 = 1073291460 (gdb) p fabs(-3) $14 = 0 (gdb) p fabs(3) $15 = 0 (gdb) p fabs(3.333) $16 = 1 (gdb) p (double) fabs(-3.234) $17 = 1 (gdb) p (double) fabs((double)-3.234) $18 = 1 (gdb) p ((double(*)(double))fabs)(-3) $19 = 682945
The code I use includes math.h, and the actual code looks correct, although the same code placed on a line in gdb produces strange results. I could ignore this, but it seems like a good opportunity to study.
ggkmath
source share