Skip to content

Commit

Permalink
#98
Browse files Browse the repository at this point in the history
  • Loading branch information
adamyg committed Jan 18, 2025
1 parent 7e6b86a commit de4d613
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 38 deletions.
74 changes: 38 additions & 36 deletions gr/m_float.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <edidentifier.h>
__CIDENT_RCSID(gr_m_float_c,"$Id: m_float.c,v 1.29 2024/12/06 15:46:06 cvsuser Exp $")
__CIDENT_RCSID(gr_m_float_c,"$Id: m_float.c,v 1.30 2025/01/18 16:25:05 cvsuser Exp $")

/* -*- mode: c; indent-width: 4; -*- */
/* $Id: m_float.c,v 1.29 2024/12/06 15:46:06 cvsuser Exp $
/* $Id: m_float.c,v 1.30 2025/01/18 16:25:05 cvsuser Exp $
* Floating point primitives.
*
*
Expand Down Expand Up @@ -136,9 +136,9 @@ __CIDENT_RCSID(gr_m_float_c,"$Id: m_float.c,v 1.29 2024/12/06 15:46:06 cvsuser E
#endif

#if defined(__WATCOMC__)
unsigned _WCNEAR _chipbug = 0; /* suppress Pentuin div checking */
unsigned _WCNEAR _chipbug = 0; /* suppress Pentuin div checking */
#endif

#define arg_float1 margv[1].l_float
#define arg_float2 margv[2].l_float
#define arg_float3 margv[3].l_float
Expand Down Expand Up @@ -204,7 +204,7 @@ matherr(struct exception *exc)
*<<GRIEF>>
Macro: isnan - Test for a NaN
int
int
isnan(float val)
Macro Description:
Expand Down Expand Up @@ -249,7 +249,7 @@ do_isnan(void) /* int (float val) */
*<<GRIEF>>
Macro: isinf - Test for infinity
int
int
isinf(float val)
Macro Description:
Expand Down Expand Up @@ -296,7 +296,7 @@ do_isinf(void) /* int (float val) */
*<<GRIEF>>
Macro: isclose - Test for floating point equality
int
int
isclose(float v1, float v2, float ~rel_tot, float ~abs_tol)
Macro Description:
Expand All @@ -307,9 +307,11 @@ do_isinf(void) /* int (float val) */
v2 - Second value to compare against.
rel_tol - Optional value, used for relative tolerance.
rel_tol - Optional non-negative value, used for relative tolerance.
Default value is 1e-09.
abs_tol - Optional value, used for the minimum absolute tolerance.
abs_tol - Optional non-negative value, used for the minimum absolute tolerance,
for values near 0. Default value is 0.0.
Macro Returns:
The 'isclose()' primitive returns a non-zero value if v1 is close in value to v2,
Expand All @@ -318,7 +320,7 @@ do_isinf(void) /* int (float val) */
Macro Portability:
A Grief extension.
Result on error are system dependent; where supported 'errno' shall be set to a
Result on error are system dependent; where supported 'errno' shall be set to a
non-zero manifest constant describing the error.
*/

Expand Down Expand Up @@ -350,7 +352,7 @@ do_isclose(void) /* int (float v1, float v2, float rel_tol = 1e09
} else if (isinf(v1) || isinf(v2)) { /* infinite never match */
acc_assign_int(0);
#elif defined(HAVE__ISINF)
} else if (_isinf(v1) || _isinf(v2)) { /* infinite never match */
} else if (_isinf(v1) || _isinf(v2)) { /* infinite never match */
acc_assign_int(0);
#endif

Expand All @@ -372,7 +374,7 @@ do_isclose(void) /* int (float v1, float v2, float rel_tol = 1e09
*<<GRIEF>>
Macro: isfinite - Test for finite value.
int
int
isfinite(float val)
Macro Description:
Expand Down Expand Up @@ -413,11 +415,11 @@ do_isfinite(void) /* int (float val) */
*<<GRIEF>>
Macro: acos - Arc cosine
float
float
acos(float x)
Macro Description:
The 'acos()' primitive shall compute the principal value of the arc cosine of the argument 'x'.
The 'acos()' primitive shall compute the principal value of the arc cosine of the argument 'x'.
The value of 'x' should be in the range [-1,1].
Macro Returns:
Expand Down Expand Up @@ -450,7 +452,7 @@ do_acos(void) /* float (float val) */
*<<GRIEF>>
Macro: asin - Arc sine
float
float
asin(float x)
Macro Description:
Expand All @@ -459,7 +461,7 @@ do_acos(void) /* float (float val) */
be in the range [-1,1].
Macro Returns:
Upon successful completion shall return the arc sine of 'x',
Upon successful completion shall return the arc sine of 'x',
in the range [-pi/2,pi/2] radians.
Macro Portability:
Expand Down Expand Up @@ -490,7 +492,7 @@ do_asin(void) /* float (float x) */
*<<GRIEF>>
Macro: atan - Arctangent
float
float
atan(float x)
Macro Description:
Expand Down Expand Up @@ -527,7 +529,7 @@ do_atan(void) /* float (float val) */
*<<GRIEF>>
Macro: atan2 - Arctangent division
float
float
atan2(float y, float x)
Macro Description:
Expand Down Expand Up @@ -569,7 +571,7 @@ do_atan2(void) /* float (float y, float x) */
*<<GRIEF>>
Macro: ceil - Round up to integral value.
float
float
ceil(float x)
Macro Description:
Expand Down Expand Up @@ -611,7 +613,7 @@ do_ceil(void) /* float (float x) */
*<<GRIEF>>
Macro: cos - Cosine
float
float
cos(float x)
Macro Description:
Expand Down Expand Up @@ -656,7 +658,7 @@ do_cos(void) /* float (float val) */
*<<GRIEF>>
Macro: cosh - Hyperbolic cosine.
float
float
cosh(float x)
Macro Description:
Expand Down Expand Up @@ -697,7 +699,7 @@ do_cosh(void) /* float (float val) */
*<<GRIEF>>
Macro: exp - Exponential function
float
float
exp(float x)
Macro Description:
Expand Down Expand Up @@ -739,7 +741,7 @@ do_exp(void) /* float (float val) */
*<<GRIEF>>
Macro: fabs - Floating-point absolute value.
float
float
fabs(float x)
Macro Description:
Expand Down Expand Up @@ -775,7 +777,7 @@ do_fabs(void) /* float (float val) */
*<<GRIEF>>
Macro: floor - Round down to integral value.
float
float
floor(float x)
Macro Description:
Expand Down Expand Up @@ -816,7 +818,7 @@ do_floor(void) /* float (float val) */
*<<GRIEF>>
Macro: fmod - Floating-point remainder.
float
float
fmod(float x, float y)
Macro Description:
Expand Down Expand Up @@ -863,7 +865,7 @@ do_fmod(void) /* float (float x, float y) */
*<<GRIEF>>
Macro: frexp - Extract mantissa and exponent
float
float
frexp(float num, int &exp)
Macro Description:
Expand Down Expand Up @@ -913,7 +915,7 @@ do_frexp(void) /* float (float val, int &exp) */
*<<GRIEF>>
Macro: ldexp - Multiply by a power of two.
float
float
ldexp(float val, int exp)
Macro Description:
Expand Down Expand Up @@ -957,7 +959,7 @@ do_ldexp(void) /* float (float val, int exp) */
*<<GRIEF>>
Macro: log - Natural logarithm.
float
float
log(float x)
Macro Description:
Expand Down Expand Up @@ -1002,7 +1004,7 @@ do_log(void) /* float (float val) */
*<<GRIEF>>
Macro: log10 - Base 10 logarithm function.
float
float
log10(float val)
Macro Description:
Expand Down Expand Up @@ -1047,7 +1049,7 @@ do_log10(void) /* float (float val) */
*<<GRIEF>>
Macro: modf - Decompose a floating-point number.
float
float
modf(float num, float &mod)
Macro Description:
Expand Down Expand Up @@ -1100,7 +1102,7 @@ do_modf(void) /* float (float val, float &mod) */
*<<GRIEF>>
Macro: pow - Raise to power.
float
float
pow(float x, float y)
Macro Description:
Expand Down Expand Up @@ -1145,7 +1147,7 @@ do_pow(void) /* float (float x, float y) */
*<<GRIEF>>
Macro: sin - Sine function.
float
float
sin(float val)
Macro Description:
Expand Down Expand Up @@ -1183,7 +1185,7 @@ do_sin(void) /* float (float val) */
*<<GRIEF>>
Macro: sinh - Hyperbolic sine function.
float
float
sinh(float val)
Macro Description:
Expand Down Expand Up @@ -1222,7 +1224,7 @@ do_sinh(void) /* float (float val) */
*<<GRIEF>>
Macro: sqrt - Square root function.
float
float
sqrt(float val)
Macro Description:
Expand Down Expand Up @@ -1261,7 +1263,7 @@ do_sqrt(void) /* float (float val) */
*<<GRIEF>>
Macro: tan - Tangent function
float
float
tan(float val)
Macro Description:
Expand Down Expand Up @@ -1299,7 +1301,7 @@ do_tan(void) /* float (float val) */
*<<GRIEF>>
Macro: tanh - Hyperbolic tangent function.
float
float
tanh(float val)
Macro Description:
Expand Down
4 changes: 2 additions & 2 deletions macsrc/demos/regress.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* -*- mode: cr; indent-width: 4; -*- */
/* $Id: regress.cr,v 1.45 2025/01/17 12:38:44 cvsuser Exp $
/* $Id: regress.cr,v 1.46 2025/01/18 16:20:34 cvsuser Exp $
*
* This set of macros are used when debugging and fixing CRISP to aid in regression testing and
* catching bugs introduced inadvertently. These tests dont attempt an exhaustive test, yet
Expand Down Expand Up @@ -1102,7 +1102,7 @@ test_math(void)
TEST(229, tan(90.0) == -1.995200412208242);
TEST(230, tan(-90.0) == 1.995200412208242);
TEST(231, tan(45.0) == 1.6197751905438615);
TEST(232, tan(60.0) == 0.320040389379563);
TEST(232, isclose(tan(60.0), 0.320040389379563, 1e13));
TEST(233, isclose(tanh(8.0), 0.9999997749296758, 1e14));
TEST(234, isclose(tanh(1.0), 0.7615941559557649, 1e14));
Expand Down

0 comments on commit de4d613

Please sign in to comment.