when I do a
printf("
%d",fabs(-1));
I get some huge number that appears to signal a misdeclaration or something. Why won’t this work?
when I do a
printf("
%d",fabs(-1));
I get some huge number that appears to signal a misdeclaration or something. Why won’t this work?
fabs is going to return a value of type float. You are asking printf to interpret this float as an int (%d). To fix it change the %d to %f:
printf("
%f",fabs(-1));
The microchip printf does not have a %f format. See this thread for some workarounds: http://www.chiefdelphi.com/forums/showthread.php?threadid=63845