Browse Source

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
mission-4.1.18
Andrew Tridgell 12 years ago
parent
commit
87e300b119
  1. 16
      libraries/AP_HAL/utility/Print.cpp
  2. 2
      libraries/AP_HAL/utility/Print.h

16
libraries/AP_HAL/utility/Print.cpp

@ -91,6 +91,14 @@ size_t Print::print(float n, int digits) @@ -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) @@ -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) {

2
libraries/AP_HAL/utility/Print.h

@ -57,6 +57,7 @@ class AP_HAL::Print { @@ -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 { @@ -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);
};

Loading…
Cancel
Save