Reformat of math library with astyle.

This commit is contained in:
jgoppert
2013-01-06 15:33:55 -05:00
parent 4f3b17f53b
commit d9491b20cc
19 changed files with 1432 additions and 1453 deletions
+40 -35
View File
@@ -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;
}
}