Go to Post ... if there is no standard against which you determine success, then you can never fail. - dlavery [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 12-02-2008, 15:04
sparrowkc sparrowkc is offline
Registered User
AKA: Mark
FRC #1986 (Team Titanium)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Lees Summit
Posts: 114
sparrowkc is a splendid one to beholdsparrowkc is a splendid one to beholdsparrowkc is a splendid one to beholdsparrowkc is a splendid one to beholdsparrowkc is a splendid one to beholdsparrowkc is a splendid one to beholdsparrowkc is a splendid one to beholdsparrowkc is a splendid one to behold
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?
  #2   Spotlight this post!  
Unread 12-02-2008, 15:07
JimWright949's Avatar
JimWright949 JimWright949 is offline
The Owen Day of Seattle
AKA: Jim Wright
FRC #4542 (Titanium Talons)
Team Role: Mentor
 
Join Date: Sep 2003
Rookie Year: 2003
Location: Redmond, WA
Posts: 94
JimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to behold
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));
  #3   Spotlight this post!  
Unread 12-02-2008, 15:49
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,563
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Perhaps I don't understand the function of fabs()

Quote:
Originally Posted by JimWright949 View Post
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
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Still don't understand how to wire IR? popnbrown Programming 1 28-01-2008 22:45
Pinning? Apparently I just don't seem to understand Brindza Rules/Strategy 61 14-03-2006 21:30
Don't Do What Seanny Don't Does Mike Iantorno General Forum 38 05-02-2003 23:56
Basketball? perhaps...read on rmadsen55 Rumor Mill 3 02-01-2003 21:37
Perhaps my biggest disappointment archiver 2001 2 23-06-2002 22:23


All times are GMT -5. The time now is 11:47.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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