aboutsummaryrefslogtreecommitdiff
path: root/src/systemcmds/tests/test_float.c
diff options
context:
space:
mode:
authorAnton Babushkin <anton.babushkin@me.com>2014-07-04 15:28:02 +0200
committerAnton Babushkin <anton.babushkin@me.com>2014-07-04 15:28:02 +0200
commit904cfd7c493e2e6f3d67ba03e9a24c14d9e62b6e (patch)
tree009971a34ecac4218edd58dd50820bb8c2b1cd3f /src/systemcmds/tests/test_float.c
parent59775efaad782a1e4f5e346832407c71f1355c89 (diff)
parent2389a11af1249f657d85d36a5e71db83940a7959 (diff)
downloadpx4-firmware-904cfd7c493e2e6f3d67ba03e9a24c14d9e62b6e.tar.gz
px4-firmware-904cfd7c493e2e6f3d67ba03e9a24c14d9e62b6e.tar.bz2
px4-firmware-904cfd7c493e2e6f3d67ba03e9a24c14d9e62b6e.zip
Merge branch 'master' into navigator_rewrite_drton
Diffstat (limited to 'src/systemcmds/tests/test_float.c')
-rw-r--r--src/systemcmds/tests/test_float.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/systemcmds/tests/test_float.c b/src/systemcmds/tests/test_float.c
index e33cc6ef7..bb8b6c7f5 100644
--- a/src/systemcmds/tests/test_float.c
+++ b/src/systemcmds/tests/test_float.c
@@ -68,7 +68,7 @@ int test_float(int argc, char *argv[])
float sinf_one = sinf(1.0f);
float sqrt_two = sqrt(2.0f);
- if (sinf_zero == 0.0f) {
+ if (fabsf(sinf_zero) < FLT_EPSILON) {
printf("\t success: sinf(0.0f) == 0.0f\n");
} else {
@@ -136,7 +136,7 @@ int test_float(int argc, char *argv[])
ret = -2;
}
- if (sqrt_two == 1.41421356f) {
+ if (fabsf(sqrt_two - 1.41421356f) < FLT_EPSILON) {
printf("\t success: sqrt(2.0f) == 1.41421f\n");
} else {
@@ -188,7 +188,7 @@ int test_float(int argc, char *argv[])
double d1d2 = d1 * d2;
- if (d1d2 == 2.022200000000000219557705349871) {
+ if (fabs(d1d2 - 2.022200000000000219557705349871) < DBL_EPSILON) {
printf("\t success: 1.0111 * 2.0 == 2.0222\n");
} else {
@@ -201,7 +201,7 @@ int test_float(int argc, char *argv[])
// Assign value of f1 to d1
d1 = f1;
- if (f1 == (float)d1) {
+ if (fabsf(f1 - (float)d1) < FLT_EPSILON) {
printf("\t success: (float) 1.55f == 1.55 (double)\n");
} else {
@@ -216,7 +216,7 @@ int test_float(int argc, char *argv[])
double sin_one = sin(1.0);
double atan2_ones = atan2(1.0, 1.0);
- if (sin_zero == 0.0) {
+ if (fabs(sin_zero - 0.0) < DBL_EPSILON) {
printf("\t success: sin(0.0) == 0.0\n");
} else {
@@ -224,7 +224,7 @@ int test_float(int argc, char *argv[])
ret = -9;
}
- if (sin_one == 0.841470984807896504875657228695) {
+ if (fabs(sin_one - 0.841470984807896504875657228695) < DBL_EPSILON) {
printf("\t success: sin(1.0) == 0.84147098480\n");
} else {
@@ -232,7 +232,7 @@ int test_float(int argc, char *argv[])
ret = -10;
}
- if (atan2_ones != 0.785398) {
+ if (fabs(atan2_ones - 0.785398) < DBL_EPSILON) {
printf("\t success: atan2(1.0, 1.0) == 0.785398\n");
} else {