View Single Post
  #3   Spotlight this post!  
Unread 05-02-2005, 15:10
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,743
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: Cannot access "double" values

I can use
double f=9.9;
without any trouble.

This Microchip implementation of printf doesn't support the printing of floats, but you can easily print them on
your own.

Code:
#define ACCURACY 1000 //How many decimal places are important to you
 
void PrintFloat(float value)
{
	long i, i2; // Don't need to be longs if you only need a few significant digits
 
	/* Separate the whole number from the fraction and print each of them */
 
	i = (long) value;
	i2 = (long) ((value-i)*ACCURACY); // You can get fancy and round by adding .5
 
	printf(" %d.%03d \r", (int)i, (int)i2); //e.g., "234.078"
}
(Been there, did this a few days ago on http://www.chiefdelphi.com/forums/sh...489#post328489)
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 05-02-2005 at 22:21. Reason: Loose use of the term "printf" caused confusion