implement epsilon (from ISO)
This commit is contained in:
parent
7223b0c9a5
commit
d18cb214fa
10
C/arith0.c
10
C/arith0.c
@ -49,6 +49,11 @@ static char SccsId[] = "%W% %G%";
|
|||||||
#define NAN (0.0/0.0)
|
#define NAN (0.0/0.0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* copied from SWI-Prolog */
|
||||||
|
#ifndef DBL_EPSILON /* normal for IEEE 64-bit double */
|
||||||
|
#define DBL_EPSILON 0.00000000000000022204
|
||||||
|
#endif
|
||||||
|
|
||||||
static Term
|
static Term
|
||||||
eval0(Int fi) {
|
eval0(Int fi) {
|
||||||
arith0_op fop = fi;
|
arith0_op fop = fi;
|
||||||
@ -61,6 +66,10 @@ eval0(Int fi) {
|
|||||||
{
|
{
|
||||||
RFLOAT(M_E);
|
RFLOAT(M_E);
|
||||||
}
|
}
|
||||||
|
case op_epsilon:
|
||||||
|
{
|
||||||
|
RFLOAT(DBL_EPSILON);
|
||||||
|
}
|
||||||
case op_inf:
|
case op_inf:
|
||||||
{
|
{
|
||||||
#ifdef _MSC_VER /* Microsoft's Visual C++ Compiler */
|
#ifdef _MSC_VER /* Microsoft's Visual C++ Compiler */
|
||||||
@ -152,6 +161,7 @@ typedef struct init_const_eval {
|
|||||||
static InitConstEntry InitConstTab[] = {
|
static InitConstEntry InitConstTab[] = {
|
||||||
{"pi", op_pi},
|
{"pi", op_pi},
|
||||||
{"e", op_e},
|
{"e", op_e},
|
||||||
|
{"epsilon", op_epsilon},
|
||||||
{"inf", op_inf},
|
{"inf", op_inf},
|
||||||
{"nan", op_nan},
|
{"nan", op_nan},
|
||||||
{"random", op_random},
|
{"random", op_random},
|
||||||
|
@ -1093,6 +1093,7 @@ static InitBinEntry InitBinTab[] = {
|
|||||||
{"\\/", op_or},
|
{"\\/", op_or},
|
||||||
{"#", op_xor},
|
{"#", op_xor},
|
||||||
{"><", op_xor},
|
{"><", op_xor},
|
||||||
|
{"atan", op_atan2},
|
||||||
{"atan2", op_atan2},
|
{"atan2", op_atan2},
|
||||||
/* C-Prolog exponentiation */
|
/* C-Prolog exponentiation */
|
||||||
{"^", op_power},
|
{"^", op_power},
|
||||||
|
4
H/eval.h
4
H/eval.h
@ -21,6 +21,9 @@
|
|||||||
#if HAVE_MATH_H
|
#if HAVE_MATH_H
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_FLOAT_H
|
||||||
|
#include <float.h>
|
||||||
|
#endif
|
||||||
#ifdef HAVE_IEEEFP_H
|
#ifdef HAVE_IEEEFP_H
|
||||||
#include <ieeefp.h>
|
#include <ieeefp.h>
|
||||||
#endif
|
#endif
|
||||||
@ -42,6 +45,7 @@
|
|||||||
typedef enum {
|
typedef enum {
|
||||||
op_pi,
|
op_pi,
|
||||||
op_e,
|
op_e,
|
||||||
|
op_epsilon,
|
||||||
op_inf,
|
op_inf,
|
||||||
op_nan,
|
op_nan,
|
||||||
op_random,
|
op_random,
|
||||||
|
@ -3776,9 +3776,12 @@ Arc cosine.
|
|||||||
@item atan(@var{X}) [ISO]
|
@item atan(@var{X}) [ISO]
|
||||||
Arc tangent.
|
Arc tangent.
|
||||||
|
|
||||||
@item atan2(@var{X})
|
@item atan(@var{X},@var{Y})
|
||||||
Four-quadrant arc tangent.
|
Four-quadrant arc tangent.
|
||||||
|
|
||||||
|
@item atan2(@var{X},@var{Y})
|
||||||
|
Four-quadrant arc tangent, same as atan/2.
|
||||||
|
|
||||||
@item sinh(@var{X})
|
@item sinh(@var{X})
|
||||||
Hyperbolic sine.
|
Hyperbolic sine.
|
||||||
|
|
||||||
@ -3930,6 +3933,10 @@ diameter.
|
|||||||
@item e
|
@item e
|
||||||
The base of the natural logarithms.
|
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
|
@item inf
|
||||||
Infinity according to the IEEE Floating-Point standard. Note that
|
Infinity according to the IEEE Floating-Point standard. Note that
|
||||||
evaluating this term will generate a domain error in the @code{iso}
|
evaluating this term will generate a domain error in the @code{iso}
|
||||||
|
Reference in New Issue
Block a user