From 4617fe118389338c6bb3f2b2ad1e5ce5a2f24ed4 Mon Sep 17 00:00:00 2001 From: neil Date: Thu, 17 Apr 2014 16:29:58 +0000 Subject: [PATCH] Keep in GCC's good books by not relying on overflow when performing addition. git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@48933 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- workbench/libs/mathffp/spdiv.c | 8 +++++--- workbench/libs/mathieeesingbas/ieeespdiv.c | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/workbench/libs/mathffp/spdiv.c b/workbench/libs/mathffp/spdiv.c index d99fea2637..d2b851de03 100644 --- a/workbench/libs/mathffp/spdiv.c +++ b/workbench/libs/mathffp/spdiv.c @@ -1,5 +1,5 @@ /* - Copyright © 1995-2004, The AROS Development Team. All rights reserved. + Copyright © 1995-2014, The AROS Development Team. All rights reserved. $Id$ */ @@ -31,13 +31,13 @@ overflow : result is out of range BUGS - The parameters are swapped ! + The parameters are swapped! INTERNALS ALGORITHM: Check if fnum2 == 0: result = 0; Check if fnum1 == 0: result = overflow; - The further algorithm comes down to a pen & paper division + The further algorithm comes down to a pen & paper division *****************************************************************************/ { @@ -94,6 +94,8 @@ /* normalize the mantisse */ while (Res > 0) { + if (Res >= 0x40000000) + Res = Res - 0x80000000; Res += Res; Exponent --; } diff --git a/workbench/libs/mathieeesingbas/ieeespdiv.c b/workbench/libs/mathieeesingbas/ieeespdiv.c index bab462066d..d6fc570f2e 100644 --- a/workbench/libs/mathieeesingbas/ieeespdiv.c +++ b/workbench/libs/mathieeesingbas/ieeespdiv.c @@ -1,5 +1,5 @@ /* - Copyright © 1995-2004, The AROS Development Team. All rights reserved. + Copyright © 1995-2014, The AROS Development Team. All rights reserved. $Id$ */ @@ -95,6 +95,8 @@ /* normalize the mantisse */ while (Res > 0) { + if (Res >= 0x40000000) + Res = Res - 0x80000000; Res += Res; Exponent -=0x00800000; } -- 2.11.4.GIT