From 3929d930c1bf851313a80905a18c751a6579aeed Mon Sep 17 00:00:00 2001 From: bernhardheld Date: Wed, 30 Apr 2003 19:56:08 +0000 Subject: [PATCH] support/regression/tests/simplefloat.c: fix division for host git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2579 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 1 + support/regression/tests/simplefloat.c | 21 +++++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5affa4d7..0250f43b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 2003-04-30 Bernhard Held * support/regression/tests/float.c: workaround 33 bit hex constant + * support/regression/tests/simplefloat.c: fix division for host 2003-04-29 Scott Dattalo diff --git a/support/regression/tests/simplefloat.c b/support/regression/tests/simplefloat.c index c5dc5f25..b19c8055 100644 --- a/support/regression/tests/simplefloat.c +++ b/support/regression/tests/simplefloat.c @@ -1,6 +1,17 @@ /** Simple set of tests for floating pt. */ #include +#include + +#if (PORT_HOST) +# define FCOMP(a,b) (fabsf((a) - (b)) < ((b) * 1e-10)) +#else + /* Testing floats for equality is normally a bug, + but too keep this test simple we dare it. And + it works with the exception of the division on + the host port. */ +# define FCOMP(a,b) ((a) == (b)) +#endif void testCmp(void) @@ -19,8 +30,7 @@ testCmp(void) void testDiv(void) { -#if !PORT_HOST -#if defined __mcs51 && !defined (SDCC_STACK_AUTO) +#if defined (__mcs51) && !defined (SDCC_STACK_AUTO) idata at 0xd0 #endif volatile float left; @@ -29,12 +39,11 @@ testDiv(void) left = 17; right = 343; - ASSERT(left/right == (17.0/343.0)); - ASSERT(right/left == (343.0/17.0)); + ASSERT(FCOMP(left/right, (17.0/343.0))); + ASSERT(FCOMP(right/left, (343.0/17.0))); right = 17; - ASSERT(left/right == 1.0); -#endif + ASSERT(FCOMP(left/right, 1.0)); } void -- 2.30.2