Thread: printf problem
View Single Post
  #1   Spotlight this post!  
Unread 30-01-2005, 12:01
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,810
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: printf problem

To print floats you can always use a little manipulation like:

Code:
#define ACCURACY 1000	//How many decimal places are important to you
float f;
int i, i2;   // Might need to be longs if you have a lot of significant digits
 
f = 245.56;
 
/* Print float value */ 
i = (int) f;
i2 = (int) ((f-i)*ACCURACY);
printf("f = %d.%d \r", i, i2); //e.g., f = 245.559
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 30-01-2005 at 12:29.