implement epsilon (from ISO)

This commit is contained in:
Vítor Manuel de Morais Santos Costa 2009-10-20 09:21:59 +01:00
parent 7223b0c9a5
commit d18cb214fa
4 changed files with 23 additions and 1 deletions

View File

@ -49,6 +49,11 @@ static char SccsId[] = "%W% %G%";
#define NAN (0.0/0.0)
#endif
/* copied from SWI-Prolog */
#ifndef DBL_EPSILON /* normal for IEEE 64-bit double */
#define DBL_EPSILON 0.00000000000000022204
#endif
static Term
eval0(Int fi) {
arith0_op fop = fi;
@ -61,6 +66,10 @@ eval0(Int fi) {
{
RFLOAT(M_E);
}
case op_epsilon:
{
RFLOAT(DBL_EPSILON);
}
case op_inf:
{
#ifdef _MSC_VER /* Microsoft's Visual C++ Compiler */
@ -152,6 +161,7 @@ typedef struct init_const_eval {
static InitConstEntry InitConstTab[] = {
{"pi", op_pi},
{"e", op_e},
{"epsilon", op_epsilon},
{"inf", op_inf},
{"nan", op_nan},
{"random", op_random},

View File

@ -1093,6 +1093,7 @@ static InitBinEntry InitBinTab[] = {
{"\\/", op_or},
{"#", op_xor},
{"><", op_xor},
{"atan", op_atan2},
{"atan2", op_atan2},
/* C-Prolog exponentiation */
{"^", op_power},

View File

@ -21,6 +21,9 @@
#if HAVE_MATH_H
#include <math.h>
#endif
#ifdef HAVE_FLOAT_H
#include <float.h>
#endif
#ifdef HAVE_IEEEFP_H
#include <ieeefp.h>
#endif
@ -42,6 +45,7 @@
typedef enum {
op_pi,
op_e,
op_epsilon,
op_inf,
op_nan,
op_random,

View File

@ -3776,9 +3776,12 @@ Arc cosine.
@item atan(@var{X}) [ISO]
Arc tangent.
@item atan2(@var{X})
@item atan(@var{X},@var{Y})
Four-quadrant arc tangent.
@item atan2(@var{X},@var{Y})
Four-quadrant arc tangent, same as atan/2.
@item sinh(@var{X})
Hyperbolic sine.
@ -3930,6 +3933,10 @@ diameter.
@item e
The base of the natural logarithms.
@item epsilon
The difference between the float @code{1.0} and the first larger floating point
number.
@item inf
Infinity according to the IEEE Floating-Point standard. Note that
evaluating this term will generate a domain error in the @code{iso}