From: MaartenBrock Date: Tue, 3 Apr 2007 12:21:50 +0000 (+0000) Subject: * device/include/math.h, X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=c8906390a11342c94da74c172d31d0c1e1fff227;p=fw%2Fsdcc * device/include/math.h, * device/lib/cotf.c, * device/lib/expf.c, * device/lib/sincoshf.c: changed XMAX to C99 HUGE_VALF git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4733 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index 3ef19fa8..d16fe4fe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-04-03 Maarten Brock + + * device/include/math.h, + * device/lib/cotf.c, + * device/lib/expf.c, + * device/lib/sincoshf.c: changed XMAX to C99 HUGE_VALF + 2007-04-01 Borut Razem * src/SDCC.lex, src/SDCCmain.c, support/cpp2/sdcpp.c: diff --git a/device/include/math.h b/device/include/math.h index fe563423..de015c35 100644 --- a/device/include/math.h +++ b/device/include/math.h @@ -1,6 +1,6 @@ /* math.h: Floating point math function declarations - Copyright (C) 2001 Jesus Calvino-Fraga, jesusc@ieee.org + Copyright (C) 2001 Jesus Calvino-Fraga, jesusc@ieee.org This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -21,6 +21,8 @@ #ifndef _INC_MATH #define _INC_MATH +#define HUGE_VALF 3.402823466e+38 + #define PI 3.1415926536 #define TWO_PI 6.2831853071 #define HALF_PI 1.5707963268 @@ -34,7 +36,6 @@ // EPS=2**(-12). Also define EPS2=EPS*EPS. #define EPS 244.14062E-6 #define EPS2 59.6046E-9 -#define XMAX 3.402823466E+38 union float_long { diff --git a/device/lib/cotf.c b/device/lib/cotf.c index 03886c12..9c5a9964 100644 --- a/device/lib/cotf.c +++ b/device/lib/cotf.c @@ -1,6 +1,6 @@ /* cotf.c: Computes cot(x) where x is a 32-bit float. - Copyright (C) 2001, 2002 Jesus Calvino-Fraga, jesusc@ieee.org + Copyright (C) 2001, 2002 Jesus Calvino-Fraga, jesusc@ieee.org This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -32,9 +32,9 @@ float cotf(const float x) _FLOAT_FUNC_REENTRANT { errno = ERANGE; if (x<0.0) - return -XMAX; + return -HUGE_VALF; else - return XMAX; + return +HUGE_VALF; } return tancotf(x, 1); } diff --git a/device/lib/expf.c b/device/lib/expf.c index 922566aa..7328100a 100644 --- a/device/lib/expf.c +++ b/device/lib/expf.c @@ -108,7 +108,7 @@ expf_range_ok: mov r3,#0x39 lcall expf_scale_and_add expf_no_range_reduction: - + // Compute e^x using the cordic algorithm. This works over an // input range of 0 to 0.69314712. Can be extended to work from @@ -318,7 +318,7 @@ fs_lshift_done: #define C1 0.693359375 #define C2 -2.1219444005469058277e-4 -#define BIGX 88.72283911 /* ln(XMAX) */ +#define BIGX 88.72283911 /* ln(HUGE_VALF) */ #define EXPEPS 1.0E-7 /* exp(1.0E-7)=0.0000001 */ #define K1 1.4426950409 /* 1/ln(2) */ @@ -340,7 +340,8 @@ float expf(const float x) if(sign) { errno=ERANGE; - return XMAX; + return HUGE_VALF + ; } else { diff --git a/device/lib/sincoshf.c b/device/lib/sincoshf.c index 644baf6a..c4e877b6 100644 --- a/device/lib/sincoshf.c +++ b/device/lib/sincoshf.c @@ -37,7 +37,7 @@ #define K2 0.24999308500451499336E+0 /* v**(-2) */ #define K3 0.13830277879601902638E-4 /* v/2-1 */ -//WMAX is defined as ln(XMAX)-ln(v)+0.69 +//WMAX is defined as ln(HUGE_VALF)-ln(v)+0.69 #define WMAX 44.93535952E+0 //WBAR 0.35*(b+1) #define WBAR 1.05 @@ -59,7 +59,7 @@ float sincoshf(const float x, const int iscosh) if (w>WMAX) { errno=ERANGE; - z=XMAX; + z=HUGE_VALF; } else {