mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-17 08:10:35 +08:00
Reformat of math library with astyle.
This commit is contained in:
@@ -44,45 +44,50 @@
|
||||
|
||||
bool __EXPORT equal(float a, float b, float epsilon)
|
||||
{
|
||||
float diff = fabsf(a-b);
|
||||
if (diff>epsilon)
|
||||
{
|
||||
printf("not equal ->\n\ta: %12.8f\n\tb: %12.8f\n", double(a), double(b));
|
||||
return false;
|
||||
}
|
||||
else return true;
|
||||
float diff = fabsf(a - b);
|
||||
|
||||
if (diff > epsilon) {
|
||||
printf("not equal ->\n\ta: %12.8f\n\tb: %12.8f\n", double(a), double(b));
|
||||
return false;
|
||||
|
||||
} else return true;
|
||||
}
|
||||
|
||||
void __EXPORT float2SigExp(
|
||||
const float & num,
|
||||
float & sig,
|
||||
int & exp)
|
||||
const float &num,
|
||||
float &sig,
|
||||
int &exp)
|
||||
{
|
||||
if (isnan(num) || isinf(num))
|
||||
{
|
||||
sig = 0.0f;
|
||||
exp = -99;
|
||||
return;
|
||||
}
|
||||
if (fabsf(num) < 1.0e-38f)
|
||||
{
|
||||
sig = 0;
|
||||
exp = 0;
|
||||
return;
|
||||
}
|
||||
exp = log10f(fabsf(num));
|
||||
if (exp>0) {
|
||||
exp = ceil(exp);
|
||||
} else {
|
||||
exp = floor(exp);
|
||||
}
|
||||
sig = num;
|
||||
// cheap power since it is integer
|
||||
if (exp>0) {
|
||||
for (int i=0;i<abs(exp);i++) sig /= 10;
|
||||
} else {
|
||||
for (int i=0;i<abs(exp);i++) sig *= 10;
|
||||
}
|
||||
if (isnan(num) || isinf(num)) {
|
||||
sig = 0.0f;
|
||||
exp = -99;
|
||||
return;
|
||||
}
|
||||
|
||||
if (fabsf(num) < 1.0e-38f) {
|
||||
sig = 0;
|
||||
exp = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
exp = log10f(fabsf(num));
|
||||
|
||||
if (exp > 0) {
|
||||
exp = ceil(exp);
|
||||
|
||||
} else {
|
||||
exp = floor(exp);
|
||||
}
|
||||
|
||||
sig = num;
|
||||
|
||||
// cheap power since it is integer
|
||||
if (exp > 0) {
|
||||
for (int i = 0; i < abs(exp); i++) sig /= 10;
|
||||
|
||||
} else {
|
||||
for (int i = 0; i < abs(exp); i++) sig *= 10;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user