Showing posts with label Floating Point. Show all posts
Showing posts with label Floating Point. Show all posts

math.h Definitions for the math floating point package.

/* math.h

Definitions for the math floating point package.

Copyright (c) Borland International 1987,1988
All Rights Reserved.
*/
#if __STDC__
#define _Cdecl
#else
#define _Cdecl cdecl
#endif

#ifndef  _MATH_H
#define  _MATH_H 1

#define EDOM 33 /* Math argument */
#define ERANGE 34 /* Result too large */

#define HUGE_VAL _huge_dble
extern double _Cdecl _huge_dble;

int _Cdecl abs   (int x);
double _Cdecl acos  (double x);
double _Cdecl asin  (double x);
double _Cdecl atan  (double x);
double _Cdecl atan2 (double y, double x);
double _Cdecl atof  (const char *s);
double _Cdecl ceil  (double x);
double _Cdecl cos   (double x);
double _Cdecl cosh  (double x);
double _Cdecl exp   (double x);
double _Cdecl fabs  (double x);
double _Cdecl floor (double x);
double _Cdecl fmod  (double x, double y);
double _Cdecl frexp (double x, int *exponent);
long _Cdecl labs  (long x);
double _Cdecl ldexp (double x, int exponent);
double _Cdecl log   (double x);
double _Cdecl log10 (double x);
double _Cdecl modf  (double x, double *ipart);
double _Cdecl pow   (double x, double y);
double _Cdecl sin   (double x);
double _Cdecl sinh  (double x);
double _Cdecl sqrt  (double x);
double _Cdecl tan   (double x);
double _Cdecl tanh  (double x);

struct exception
{
int type;
char   *name;
double arg1, arg2, retval;
};

int _Cdecl matherr (struct exception *e);

#if !__STDC__
double cdecl hypot (double x, double y);
double cdecl poly  (double x, int degree, double coeffs []);
double cdecl pow10 (int p);

struct complex    /* as used by "cabs" function */
{
    double  x, y;
};

#define cabs(z)     (hypot ((z).x, (z).y))

/*  The customary matherr() exception handler for maths functions is
    not compatible with the x3j11 draft standard for C.  _matherr() is
    provided as a compromise.
*/

typedef enum
{
    DOMAIN = 1,    /* argument domain error -- log (-1)        */
    SING,   /* argument singularity  -- pow (0,-2))     */
    OVERFLOW,   /* overflow range error  -- exp (1000)      */
    UNDERFLOW,   /* underflow range error -- exp (-1000)     */
    TLOSS,   /* total loss of significance -- sin(10e70) */
    PLOSS,   /* partial loss of signif. -- not used      */
}   _mexcep;

double _Cdecl _matherr (_mexcep why, char *fun, double  *arg1p,
double  *arg2p, double  retval);

/* Constants rounded for 21 decimals. */
#define M_E 2.71828182845904523536
#define M_LOG2E 1.44269504088896340736
#define M_LOG10E 0.434294481903251827651
#define M_LN2 0.693147180559945309417
#define M_LN10 2.30258509299404568402
#define M_PI 3.14159265358979323846
#define M_PI_2 1.57079632679489661923
#define M_PI_4 0.785398163397448309116
#define M_1_PI 0.318309886183790671538
#define M_2_PI 0.636619772367581343076
#define M_1_SQRTPI 0.564189583547756286948
#define M_2_SQRTPI 1.12837916709551257390
#define M_SQRT2 1.41421356237309504880
#define M_SQRT_2 0.707106781186547524401

#endif /* __STDC__ */

#endif

float.h Defines implementation specific macros for dealing with floating point.


Copyright (c) Borland International 1987,1988
All Rights Reserved.
*/
#if __STDC__
#define _Cdecl
#else
#define _Cdecl cdecl
#endif

#define FLT_RADIX 2
#define FLT_ROUNDS 1
#define FLT_GUARD 1
#define FLT_NORMALIZE 1

#define DBL_DIG 15
#define FLT_DIG 6
#define LDBL_DIG 19

#define DBL_MANT_DIG 53
#define FLT_MANT_DIG 24
#define LDBL_MANT_DIG 64

#define DBL_EPSILON 2.2204460492503131E-16
#define FLT_EPSILON 1.19209290E-07F
#define LDBL_EPSILON 1.084202172485504E-19

/* smallest positive IEEE normal numbers */
#define DBL_MIN 2.2250738585072014E-308
#define FLT_MIN 1.17549435E-38F
#define LDBL_MIN _tiny_ldble

#define DBL_MAX _huge_dble
#define FLT_MAX _huge_flt
#define LDBL_MAX _huge_ldble

#define DBL_MAX_EXP +1024
#define FLT_MAX_EXP +128
#define LDBL_MAX_EXP +16384

#define DBL_MAX_10_EXP +308
#define FLT_MAX_10_EXP +38
#define LDBL_MAX_10_EXP +4932

#define DBL_MIN_10_EXP -307
#define FLT_MIN_10_EXP -37
#define LDBL_MIN_10_EXP -4931

#define DBL_MIN_EXP -1021
#define FLT_MIN_EXP -125
#define LDBL_MIN_EXP -16381

extern float _Cdecl _huge_flt;
extern double _Cdecl _huge_dble;
extern long double _Cdecl _huge_ldble;
extern long double _Cdecl _tiny_ldble;

unsigned int _Cdecl _clear87(void);
unsigned int _Cdecl _control87(unsigned int new, unsigned int mask);
void     _Cdecl _fpreset(void);
unsigned int _Cdecl _status87(void);

/* 8087/80287 Status Word format   */

#define SW_INVALID 0x0001 /* Invalid operation */
#define SW_DENORMAL 0x0002 /* Denormalized operand */
#define SW_ZERODIVIDE 0x0004 /* Zero divide */
#define SW_OVERFLOW 0x0008 /* Overflow */
#define SW_UNDERFLOW 0x0010 /* Underflow */
#define SW_INEXACT 0x0020 /* Precision (Inexact result) */

/* 8087/80287 Control Word format */

#define MCW_EM 0x003f /* interrupt Exception Masks */
#define    EM_INVALID 0x0001 /*   invalid */
#define    EM_DENORMAL 0x0002 /*   denormal */
#define    EM_ZERODIVIDE 0x0004 /*   zero divide */
#define    EM_OVERFLOW 0x0008 /*   overflow */
#define    EM_UNDERFLOW 0x0010 /*   underflow */
#define    EM_INEXACT 0x0020 /*   inexact (precision) */

#define MCW_IC 0x1000 /* Infinity Control */
#define    IC_AFFINE 0x1000 /*   affine */
#define    IC_PROJECTIVE 0x0000 /*   projective */

#define MCW_RC 0x0c00 /* Rounding Control */
#define    RC_CHOP 0x0c00 /*   chop */
#define    RC_UP 0x0800 /*   up */
#define    RC_DOWN 0x0400 /*   down */
#define    RC_NEAR 0x0000 /*   near */

#define MCW_PC 0x0300 /* Precision Control */
#define    PC_24 0x0000 /*    24 bits */
#define    PC_53 0x0200 /*    53 bits */
#define    PC_64 0x0300 /*    64 bits */

/* 8087/80287 Initial Control Word */
/* use affine infinity, mask underflow and precision exceptions */

#define CW_DEFAULT (RC_NEAR+PC_64+IC_AFFINE+EM_UNDERFLOW+EM_INEXACT)

/*
SIGFPE signal error types (for integer & float exceptions).
*/
#define FPE_INTOVFLOW 126 /* 80x86 Interrupt on overflow */
#define FPE_INTDIV0 127 /* 80x86 Integer divide by zero */

#define FPE_INVALID 129 /* 80x87 invalid operation */
#define FPE_ZERODIVIDE 131 /* 80x87 divide by zero */
#define FPE_OVERFLOW 132 /* 80x87 arithmetic overflow */
#define FPE_UNDERFLOW 133 /* 80x87 arithmetic underflow */
#define FPE_INEXACT 134 /* 80x87 precision loss */
#define FPE_EXPLICITGEN 140 /* When SIGFPE is raise()'d */

/*
SIGSEGV signal error types.
*/
#define SEGV_BOUND 10 /* A BOUND violation (SIGSEGV) */
#define SEGV_EXPLICITGEN 11 /* When SIGSEGV is raise()'d */

/*
SIGILL signal error types.
*/
#define ILL_EXECUTION 20 /* Illegal operation exception */
#define ILL_EXPLICITGEN 21 /* When SIGILL is raise()'d */