Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Perhaps I don't understand the function of fabs() (http://www.chiefdelphi.com/forums/showthread.php?t=63881)

sparrowkc 12-02-2008 15:04

Perhaps I don't understand the function of fabs()
 
when I do a
printf("\r\n%d",fabs(-1));

I get some huge number that appears to signal a misdeclaration or something. Why won't this work?

JimWright949 12-02-2008 15:07

Re: Perhaps I don't understand the function of fabs()
 
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("\r\n%f",fabs(-1));

Joe Ross 12-02-2008 15:49

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

Originally Posted by JimWright949 (Post 697430)
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("\r\n%f",fabs(-1));

The microchip printf does not have a %f format. See this thread for some workarounds: http://www.chiefdelphi.com/forums/sh...threadid=63845


All times are GMT -5. The time now is 00:58.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi