Perhaps I don't understand the function of fabs()

when I do a

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:

The microchip printf does not have a %f format. See this thread for some workarounds: