Thread: printf problem
View Single Post
  #2   Spotlight this post!  
Unread 29-01-2005, 08:38
logicalhippo logicalhippo is offline
Registered User
AKA: Russell McClellan
#0213 (Dirty Birds)
Team Role: Programmer
 
Join Date: Jan 2005
Rookie Year: 2003
Location: Keene, NH
Posts: 11
logicalhippo is an unknown quantity at this point
Send a message via AIM to logicalhippo
Re: printf problem

printf does not support printing of floating points :'(. sorry, it just doesn't work. (see the comment in printf_lib.c)
What SHOULD work is using %d and then explicitly casting the float to an int.
IE: printf("%d\n", (int)fFloat);
Unfortunately, for me, this ALWAYS prints 0, no matter how large fFloat is.
I'm still having trouble with how to convert floats to ints. I wrote a quick function in c that I'm going to test today, and I found assembly routines from 1997 (see product note AN575 on microchip's page) that I will try.

Around here the consensus seems to be that floating points are more trouble than they are worth on this processor. In most cases where you would use floating point on the robot it's possible to do the math in the integer domain by multiplying first then dividing down.