Go Down

Topic: Variable precision printing of floats (Read 578 times) previous topic - next topic

EmilyJane

I've been using this function from the Print library to print floats:

Code: [Select]
void Print::printFloat(double number, uint8_t digits)

It is currently a private, but is making it available to the Print class as simple as moving it down into the publics in Print.h?


EmilyJane

Cool. And if I delete Print.cpp.o, it will recompile automagically?

retrolefty


mem

#4
Jul 23, 2009, 05:11 am Last Edit: Jul 23, 2009, 05:12 am by mem Reason: 1
If you are going to modify the class, adding the following two methods are a more consistent way of getting the functionality you are looking for (of course you need to declare these in the h file as well)

Code: [Select]
void Print::print(double n, uint8_t digits)
{
 printFloat(n, digits);
}

void Print::println(double n, uint8_t digits)
{
 printFloat(n, digits);
 println();
}

I expect the Arduino team will be supporting user settable precision in future using this syntax.

EmilyJane

Yes, that preserves the orthogonality. That's the way I'll do it.

Quote
I expect the Arduino team will be supporting user settable precision in future using this syntax


And maybe even the Reference page as well... ;)

Go Up