AP_HAL: added double print functions

this copes with the fact that the compiler doesn't really know that
float and double are the same things
This commit is contained in:
Andrew Tridgell 2012-10-27 10:54:05 +11:00
parent e663f5feab
commit 87e300b119
2 changed files with 18 additions and 0 deletions

View File

@ -91,6 +91,14 @@ size_t Print::print(float n, int digits)
return printFloat(n, digits);
}
// the compiler promotes to double if we do arithmetic in the
// argument, but we only actually want float precision, so just wrap
// it with a double method
size_t Print::print(double n, int digits)
{
return print((float)n, digits);
}
size_t Print::println(void)
{
size_t n = print('\r');
@ -154,6 +162,14 @@ size_t Print::println(float num, int digits)
return n;
}
// the compiler promotes to double if we do arithmetic in the
// argument, but we only actually want float precision, so just wrap
// it with a double method
size_t Print::println(double num, int digits)
{
return println((float)num, digits);
}
// Private Methods /////////////////////////////////////////////////////////////
size_t Print::printNumber(unsigned long n, uint8_t base) {

View File

@ -57,6 +57,7 @@ class AP_HAL::Print {
size_t print(long, int = DEC);
size_t print(unsigned long, int = DEC);
size_t print(float , int = 2);
size_t print(double , int = 2);
size_t println(const char[]);
size_t println(char);
@ -66,6 +67,7 @@ class AP_HAL::Print {
size_t println(long, int = DEC);
size_t println(unsigned long, int = DEC);
size_t println(float , int = 2);
size_t println(double , int = 2);
size_t println(void);
};