View Single Post
  #9   Spotlight this post!  
Unread 28-01-2007, 23:59
DanDon's Avatar
DanDon DanDon is offline
ohhh MY god
AKA: Dan Hoizner
FRC #0375 (The Robotic Plague)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Staten Island, NY
Posts: 1,432
DanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond repute
Send a message via ICQ to DanDon Send a message via AIM to DanDon Send a message via MSN to DanDon
Re: Reading battery voltage in software

If I recall correctly the printf functions in our code don't support the %f sequence. If the decimal place does not matter to you, just cast the variable as an int when printing it out (i.e. (int)variable). If you do want the decimal places, do something like:

Code:
variabledeci = variable - (int)variable; 

variabledeci*=1000; 

printf("variable = %d.%03d", (int)variable, (int)variabledeci);
This stores the decimal portion of the variable in another one, then multiplies by 1000 to get the decimals in front of the decimal point, and then prints the whole thing out.
__________________