Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
defb5dab
Commit
defb5dab
authored
Apr 21, 1994
by
Richard Kenner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upate comments and copyright notice.
From-SVN: r7130
parent
ac4cf5d9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
344 additions
and
590 deletions
+344
-590
gcc/real.c
+344
-590
No files found.
gcc/real.c
View file @
defb5dab
...
@@ -58,10 +58,9 @@ transcendental functions can be obtained by ftp from
...
@@ -58,10 +58,9 @@ transcendental functions can be obtained by ftp from
research.att.com: netlib/cephes/ldouble.shar.Z */
research.att.com: netlib/cephes/ldouble.shar.Z */
/* Type of computer arithmetic.
/* Type of computer arithmetic.
* Only one of DEC, IBM, MIEEE, IBMPC, or UNK should get defined.
Only one of DEC, IBM, MIEEE, IBMPC, or UNK should get defined.
*/
/*
`MIEEE' refers generically to big-endian IEEE floating-point data
`MIEEE' refers generically to big-endian IEEE floating-point data
structure. This definition should work in SFmode `float' type and
structure. This definition should work in SFmode `float' type and
DFmode `double' type on virtually all big-endian IEEE machines.
DFmode `double' type on virtually all big-endian IEEE machines.
If LONG_DOUBLE_TYPE_SIZE has been defined to be 96, then MIEEE
If LONG_DOUBLE_TYPE_SIZE has been defined to be 96, then MIEEE
...
@@ -142,6 +141,7 @@ unknown arithmetic type
...
@@ -142,6 +141,7 @@ unknown arithmetic type
target machine's structure and will get its ends swapped
target machine's structure and will get its ends swapped
accordingly (but not here). Probably only the decimal <-> binary
accordingly (but not here). Probably only the decimal <-> binary
functions in this file will actually be used in this case. */
functions in this file will actually be used in this case. */
#if HOST_FLOAT_FORMAT == VAX_FLOAT_FORMAT
#if HOST_FLOAT_FORMAT == VAX_FLOAT_FORMAT
#define DEC 1
#define DEC 1
#else
/* it's not VAX */
#else
/* it's not VAX */
...
@@ -530,8 +530,7 @@ endian (e, x, mode)
...
@@ -530,8 +530,7 @@ endian (e, x, mode)
}
}
/* This is the implementation of the REAL_ARITHMETIC macro.
/* This is the implementation of the REAL_ARITHMETIC macro. */
*/
void
void
earith
(
value
,
icode
,
r1
,
r2
)
earith
(
value
,
icode
,
r1
,
r2
)
...
@@ -609,9 +608,9 @@ PUT_REAL (v, value);
...
@@ -609,9 +608,9 @@ PUT_REAL (v, value);
}
}
/* Truncate REAL_VALUE_TYPE toward zero to signed HOST_WIDE_INT
/* Truncate REAL_VALUE_TYPE toward zero to signed HOST_WIDE_INT
.
* implements REAL_VALUE_RNDZINT (x) (etrunci (x))
implements REAL_VALUE_RNDZINT (x) (etrunci (x)). */
*/
REAL_VALUE_TYPE
REAL_VALUE_TYPE
etrunci
(
x
)
etrunci
(
x
)
REAL_VALUE_TYPE
x
;
REAL_VALUE_TYPE
x
;
...
@@ -632,9 +631,9 @@ etrunci (x)
...
@@ -632,9 +631,9 @@ etrunci (x)
}
}
/* Truncate REAL_VALUE_TYPE toward zero to unsigned HOST_WIDE_INT
/* Truncate REAL_VALUE_TYPE toward zero to unsigned HOST_WIDE_INT
;
* implements REAL_VALUE_UNSIGNED_RNDZINT (x) (etruncui (x))
implements REAL_VALUE_UNSIGNED_RNDZINT (x) (etruncui (x)). */
*/
REAL_VALUE_TYPE
REAL_VALUE_TYPE
etruncui
(
x
)
etruncui
(
x
)
REAL_VALUE_TYPE
x
;
REAL_VALUE_TYPE
x
;
...
@@ -655,11 +654,10 @@ etruncui (x)
...
@@ -655,11 +654,10 @@ etruncui (x)
}
}
/* This is the REAL_VALUE_ATOF function.
/* This is the REAL_VALUE_ATOF function. It converts a decimal string to
* It converts a decimal string to binary, rounding off
binary, rounding off as indicated by the machine_mode argument. Then it
* as indicated by the machine_mode argument. Then it
promotes the rounded value to REAL_VALUE_TYPE. */
* promotes the rounded value to REAL_VALUE_TYPE.
*/
REAL_VALUE_TYPE
REAL_VALUE_TYPE
ereal_atof
(
s
,
t
)
ereal_atof
(
s
,
t
)
char
*
s
;
char
*
s
;
...
@@ -694,8 +692,8 @@ ereal_atof (s, t)
...
@@ -694,8 +692,8 @@ ereal_atof (s, t)
}
}
/* Expansion of REAL_NEGATE.
/* Expansion of REAL_NEGATE.
*/
*/
REAL_VALUE_TYPE
REAL_VALUE_TYPE
ereal_negate
(
x
)
ereal_negate
(
x
)
REAL_VALUE_TYPE
x
;
REAL_VALUE_TYPE
x
;
...
@@ -710,9 +708,9 @@ ereal_negate (x)
...
@@ -710,9 +708,9 @@ ereal_negate (x)
}
}
/* Round real toward zero to HOST_WIDE_INT
/* Round real toward zero to HOST_WIDE_INT
;
* implements REAL_VALUE_FIX (x).
implements REAL_VALUE_FIX (x). */
*/
HOST_WIDE_INT
HOST_WIDE_INT
efixi
(
x
)
efixi
(
x
)
REAL_VALUE_TYPE
x
;
REAL_VALUE_TYPE
x
;
...
@@ -733,9 +731,9 @@ efixi (x)
...
@@ -733,9 +731,9 @@ efixi (x)
}
}
/* Round real toward zero to unsigned HOST_WIDE_INT
/* Round real toward zero to unsigned HOST_WIDE_INT
*
implements REAL_VALUE_UNSIGNED_FIX (x).
implements REAL_VALUE_UNSIGNED_FIX (x).
* Negative input returns zero.
Negative input returns zero. */
*/
unsigned
HOST_WIDE_INT
unsigned
HOST_WIDE_INT
efixui
(
x
)
efixui
(
x
)
REAL_VALUE_TYPE
x
;
REAL_VALUE_TYPE
x
;
...
@@ -756,8 +754,8 @@ efixui (x)
...
@@ -756,8 +754,8 @@ efixui (x)
}
}
/* REAL_VALUE_FROM_INT macro.
/* REAL_VALUE_FROM_INT macro.
*/
*/
void
void
ereal_from_int
(
d
,
i
,
j
)
ereal_from_int
(
d
,
i
,
j
)
REAL_VALUE_TYPE
*
d
;
REAL_VALUE_TYPE
*
d
;
...
@@ -790,8 +788,7 @@ ereal_from_int (d, i, j)
...
@@ -790,8 +788,7 @@ ereal_from_int (d, i, j)
}
}
/* REAL_VALUE_FROM_UNSIGNED_INT macro.
/* REAL_VALUE_FROM_UNSIGNED_INT macro. */
*/
void
void
ereal_from_uint
(
d
,
i
,
j
)
ereal_from_uint
(
d
,
i
,
j
)
...
@@ -812,8 +809,8 @@ ereal_from_uint (d, i, j)
...
@@ -812,8 +809,8 @@ ereal_from_uint (d, i, j)
}
}
/* REAL_VALUE_TO_INT macro
/* REAL_VALUE_TO_INT macro
. */
*/
void
void
ereal_to_int
(
low
,
high
,
rr
)
ereal_to_int
(
low
,
high
,
rr
)
HOST_WIDE_INT
*
low
,
*
high
;
HOST_WIDE_INT
*
low
,
*
high
;
...
@@ -856,8 +853,8 @@ ereal_to_int (low, high, rr)
...
@@ -856,8 +853,8 @@ ereal_to_int (low, high, rr)
}
}
/* REAL_VALUE_LDEXP macro.
/* REAL_VALUE_LDEXP macro.
*/
*/
REAL_VALUE_TYPE
REAL_VALUE_TYPE
ereal_ldexp
(
x
,
n
)
ereal_ldexp
(
x
,
n
)
REAL_VALUE_TYPE
x
;
REAL_VALUE_TYPE
x
;
...
@@ -877,10 +874,12 @@ ereal_ldexp (x, n)
...
@@ -877,10 +874,12 @@ ereal_ldexp (x, n)
}
}
/* These routines are conditionally compiled because functions
/* These routines are conditionally compiled because functions
* of the same names may be defined in fold-const.c. */
of the same names may be defined in fold-const.c. */
#ifdef REAL_ARITHMETIC
#ifdef REAL_ARITHMETIC
/* Check for infinity in a REAL_VALUE_TYPE. */
/* Check for infinity in a REAL_VALUE_TYPE. */
int
int
target_isinf
(
x
)
target_isinf
(
x
)
REAL_VALUE_TYPE
x
;
REAL_VALUE_TYPE
x
;
...
@@ -914,8 +913,7 @@ target_isnan (x)
...
@@ -914,8 +913,7 @@ target_isnan (x)
/* Check for a negative REAL_VALUE_TYPE number.
/* Check for a negative REAL_VALUE_TYPE number.
* This just checks the sign bit, so that -0 counts as negative.
This just checks the sign bit, so that -0 counts as negative. */
*/
int
int
target_negative
(
x
)
target_negative
(
x
)
...
@@ -925,8 +923,8 @@ target_negative (x)
...
@@ -925,8 +923,8 @@ target_negative (x)
}
}
/* Expansion of REAL_VALUE_TRUNCATE.
/* Expansion of REAL_VALUE_TRUNCATE.
* The result is in floating point, rounded to nearest or even.
The result is in floating point, rounded to nearest or even. */
*/
REAL_VALUE_TYPE
REAL_VALUE_TYPE
real_value_truncate
(
mode
,
arg
)
real_value_truncate
(
mode
,
arg
)
enum
machine_mode
mode
;
enum
machine_mode
mode
;
...
@@ -970,6 +968,7 @@ real_value_truncate (mode, arg)
...
@@ -970,6 +968,7 @@ real_value_truncate (mode, arg)
/* If an unsupported type was requested, presume that
/* If an unsupported type was requested, presume that
the machine files know something useful to do with
the machine files know something useful to do with
the unmodified value. */
the unmodified value. */
default
:
default
:
return
(
arg
);
return
(
arg
);
}
}
...
@@ -997,6 +996,7 @@ debug_real (r)
...
@@ -997,6 +996,7 @@ debug_real (r)
to be at least 32 bits wide. */
to be at least 32 bits wide. */
/* 128-bit long double */
/* 128-bit long double */
void
void
etartdouble
(
r
,
l
)
etartdouble
(
r
,
l
)
REAL_VALUE_TYPE
r
;
REAL_VALUE_TYPE
r
;
...
@@ -1010,6 +1010,7 @@ etartdouble (r, l)
...
@@ -1010,6 +1010,7 @@ etartdouble (r, l)
}
}
/* 80-bit long double */
/* 80-bit long double */
void
void
etarldouble
(
r
,
l
)
etarldouble
(
r
,
l
)
REAL_VALUE_TYPE
r
;
REAL_VALUE_TYPE
r
;
...
@@ -1081,185 +1082,159 @@ ereal_isneg (x)
...
@@ -1081,185 +1082,159 @@ ereal_isneg (x)
/* End of REAL_ARITHMETIC interface */
/* End of REAL_ARITHMETIC interface */
/* ieee.c
/*
*
Extended precision IEEE binary floating point arithmetic routines
* Extended precision IEEE binary floating point arithmetic routines
*
Numbers are stored in C language as arrays of 16-bit unsigned
* Numbers are stored in C language as arrays of 16-bit unsigned
short integers. The arguments of the routines are pointers to
* short integers. The arguments of the routines are pointers to
the arrays.
* the arrays.
*
External e type data structure, simulates Intel 8087 chip
*
temporary real format but possibly with a larger significand:
* External e type data structure, simulates Intel 8087 chip
* temporary real format but possibly with a larger significand:
NE-1 significand words (least significant word first,
*
most significant bit is normally set)
* NE-1 significand words (least significant word first,
exponent (value = EXONE for 1.0,
* most significant bit is normally set)
top bit is the sign)
* exponent (value = EXONE for 1.0,
* top bit is the sign)
*
Internal data structure of a number (a "word" is 16 bits):
*
* Internal data structure of a number (a "word" is 16 bits):
ei[0] sign word (0 for positive, 0xffff for negative)
*
ei[1] biased exponent (value = EXONE for the number 1.0)
* ei[0] sign word (0 for positive, 0xffff for negative)
ei[2] high guard word (always zero after normalization)
* ei[1] biased exponent (value = EXONE for the number 1.0)
ei[3]
* ei[2] high guard word (always zero after normalization)
to ei[NI-2] significand (NI-4 significand words,
* ei[3]
most significant word first,
* to ei[NI-2] significand (NI-4 significand words,
most significant bit is set)
* most significant word first,
ei[NI-1] low guard word (0x8000 bit is rounding place)
* most significant bit is set)
* ei[NI-1] low guard word (0x8000 bit is rounding place)
*
*
Routines for external format numbers
*
* Routines for external format numbers
asctoe (string, e) ASCII string to extended double e type
*
asctoe64 (string, &d) ASCII string to long double
* asctoe (string, e) ASCII string to extended double e type
asctoe53 (string, &d) ASCII string to double
* asctoe64 (string, &d) ASCII string to long double
asctoe24 (string, &f) ASCII string to single
* asctoe53 (string, &d) ASCII string to double
asctoeg (string, e, prec) ASCII string to specified precision
* asctoe24 (string, &f) ASCII string to single
e24toe (&f, e) IEEE single precision to e type
* asctoeg (string, e, prec) ASCII string to specified precision
e53toe (&d, e) IEEE double precision to e type
* e24toe (&f, e) IEEE single precision to e type
e64toe (&d, e) IEEE long double precision to e type
* e53toe (&d, e) IEEE double precision to e type
e113toe (&d, e) 128-bit long double precision to e type
* e64toe (&d, e) IEEE long double precision to e type
eabs (e) absolute value
* e113toe (&d, e) 128-bit long double precision to e type
eadd (a, b, c) c = b + a
* eabs (e) absolute value
eclear (e) e = 0
* eadd (a, b, c) c = b + a
ecmp (a, b) Returns 1 if a > b, 0 if a == b,
* eclear (e) e = 0
-1 if a < b, -2 if either a or b is a NaN.
* ecmp (a, b) Returns 1 if a > b, 0 if a == b,
ediv (a, b, c) c = b / a
* -1 if a < b, -2 if either a or b is a NaN.
efloor (a, b) truncate to integer, toward -infinity
* ediv (a, b, c) c = b / a
efrexp (a, exp, s) extract exponent and significand
* efloor (a, b) truncate to integer, toward -infinity
eifrac (e, &l, frac) e to HOST_WIDE_INT and e type fraction
* efrexp (a, exp, s) extract exponent and significand
euifrac (e, &l, frac) e to unsigned HOST_WIDE_INT and e type fraction
* eifrac (e, &l, frac) e to HOST_WIDE_INT and e type fraction
einfin (e) set e to infinity, leaving its sign alone
* euifrac (e, &l, frac) e to unsigned HOST_WIDE_INT and e type fraction
eldexp (a, n, b) multiply by 2**n
* einfin (e) set e to infinity, leaving its sign alone
emov (a, b) b = a
* eldexp (a, n, b) multiply by 2**n
emul (a, b, c) c = b * a
* emov (a, b) b = a
eneg (e) e = -e
* emul (a, b, c) c = b * a
eround (a, b) b = nearest integer value to a
* eneg (e) e = -e
esub (a, b, c) c = b - a
* eround (a, b) b = nearest integer value to a
e24toasc (&f, str, n) single to ASCII string, n digits after decimal
* esub (a, b, c) c = b - a
e53toasc (&d, str, n) double to ASCII string, n digits after decimal
* e24toasc (&f, str, n) single to ASCII string, n digits after decimal
e64toasc (&d, str, n) 80-bit long double to ASCII string
* e53toasc (&d, str, n) double to ASCII string, n digits after decimal
e113toasc (&d, str, n) 128-bit long double to ASCII string
* e64toasc (&d, str, n) 80-bit long double to ASCII string
etoasc (e, str, n) e to ASCII string, n digits after decimal
* e113toasc (&d, str, n) 128-bit long double to ASCII string
etoe24 (e, &f) convert e type to IEEE single precision
* etoasc (e, str, n) e to ASCII string, n digits after decimal
etoe53 (e, &d) convert e type to IEEE double precision
* etoe24 (e, &f) convert e type to IEEE single precision
etoe64 (e, &d) convert e type to IEEE long double precision
* etoe53 (e, &d) convert e type to IEEE double precision
ltoe (&l, e) HOST_WIDE_INT to e type
* etoe64 (e, &d) convert e type to IEEE long double precision
ultoe (&l, e) unsigned HOST_WIDE_INT to e type
* ltoe (&l, e) HOST_WIDE_INT to e type
eisneg (e) 1 if sign bit of e != 0, else 0
* ultoe (&l, e) unsigned HOST_WIDE_INT to e type
eisinf (e) 1 if e has maximum exponent (non-IEEE)
* eisneg (e) 1 if sign bit of e != 0, else 0
or is infinite (IEEE)
* eisinf (e) 1 if e has maximum exponent (non-IEEE)
eisnan (e) 1 if e is a NaN
* or is infinite (IEEE)
* eisnan (e) 1 if e is a NaN
*
Routines for internal format numbers
*
* Routines for internal format numbers
eaddm (ai, bi) add significands, bi = bi + ai
*
ecleaz (ei) ei = 0
* eaddm (ai, bi) add significands, bi = bi + ai
ecleazs (ei) set ei = 0 but leave its sign alone
* ecleaz (ei) ei = 0
ecmpm (ai, bi) compare significands, return 1, 0, or -1
* ecleazs (ei) set ei = 0 but leave its sign alone
edivm (ai, bi) divide significands, bi = bi / ai
* ecmpm (ai, bi) compare significands, return 1, 0, or -1
emdnorm (ai,l,s,exp) normalize and round off
* edivm (ai, bi) divide significands, bi = bi / ai
emovi (a, ai) convert external a to internal ai
* emdnorm (ai,l,s,exp) normalize and round off
emovo (ai, a) convert internal ai to external a
* emovi (a, ai) convert external a to internal ai
emovz (ai, bi) bi = ai, low guard word of bi = 0
* emovo (ai, a) convert internal ai to external a
emulm (ai, bi) multiply significands, bi = bi * ai
* emovz (ai, bi) bi = ai, low guard word of bi = 0
enormlz (ei) left-justify the significand
* emulm (ai, bi) multiply significands, bi = bi * ai
eshdn1 (ai) shift significand and guards down 1 bit
* enormlz (ei) left-justify the significand
eshdn8 (ai) shift down 8 bits
* eshdn1 (ai) shift significand and guards down 1 bit
eshdn6 (ai) shift down 16 bits
* eshdn8 (ai) shift down 8 bits
eshift (ai, n) shift ai n bits up (or down if n < 0)
* eshdn6 (ai) shift down 16 bits
eshup1 (ai) shift significand and guards up 1 bit
* eshift (ai, n) shift ai n bits up (or down if n < 0)
eshup8 (ai) shift up 8 bits
* eshup1 (ai) shift significand and guards up 1 bit
eshup6 (ai) shift up 16 bits
* eshup8 (ai) shift up 8 bits
esubm (ai, bi) subtract significands, bi = bi - ai
* eshup6 (ai) shift up 16 bits
eiisinf (ai) 1 if infinite
* esubm (ai, bi) subtract significands, bi = bi - ai
eiisnan (ai) 1 if a NaN
* eiisinf (ai) 1 if infinite
eiisneg (ai) 1 if sign bit of ai != 0, else 0
* eiisnan (ai) 1 if a NaN
einan (ai) set ai = NaN
* eiisneg (ai) 1 if sign bit of ai != 0, else 0
eiinfin (ai) set ai = infinity
* einan (ai) set ai = NaN
* eiinfin (ai) set ai = infinity
The result is always normalized and rounded to NI-4 word precision
*
after each arithmetic operation.
*
* The result is always normalized and rounded to NI-4 word precision
Exception flags are NOT fully supported.
* after each arithmetic operation.
*
Signaling NaN's are NOT supported; they are treated the same
* Exception flags are NOT fully supported.
as quiet NaN's.
*
* Signaling NaN's are NOT supported; they are treated the same
Define INFINITY for support of infinity; otherwise a
* as quiet NaN's.
saturation arithmetic is implemented.
*
* Define INFINITY for support of infinity; otherwise a
Define NANS for support of Not-a-Number items; otherwise the
* saturation arithmetic is implemented.
arithmetic will never produce a NaN output, and might be confused
*
by a NaN input.
* Define NANS for support of Not-a-Number items; otherwise the
If NaN's are supported, the output of `ecmp (a,b)' is -2 if
* arithmetic will never produce a NaN output, and might be confused
either a or b is a NaN. This means asking `if (ecmp (a,b) < 0)'
* by a NaN input.
may not be legitimate. Use `if (ecmp (a,b) == -1)' for `less than'
* If NaN's are supported, the output of `ecmp (a,b)' is -2 if
if in doubt.
* either a or b is a NaN. This means asking `if (ecmp (a,b) < 0)'
* may not be legitimate. Use `if (ecmp (a,b) == -1)' for `less than'
Denormals are always supported here where appropriate (e.g., not
* if in doubt.
for conversion to DEC numbers). */
*
* Denormals are always supported here where appropriate (e.g., not
/* Definitions for error codes that are passed to the common error handling
* for conversion to DEC numbers).
routine mtherr.
*
*/
For Digital Equipment PDP-11 and VAX computers, certain
IBM systems, and others that use numbers with a 56-bit
significand, the symbol DEC should be defined. In this
/* mconf.h
mode, most floating point constants are given as arrays
*
of octal integers to eliminate decimal to binary conversion
* Common include file for math routines
errors that might be introduced by the compiler.
*
*
For computers, such as IBM PC, that follow the IEEE
*
Standard for Binary Floating Point Arithmetic (ANSI/IEEE
* SYNOPSIS:
Std 754-1985), the symbol IBMPC or MIEEE should be defined.
*
These numbers have 53-bit significands. In this mode, constants
* #include "mconf.h"
are provided as arrays of hexadecimal 16 bit integers.
*
*
To accommodate other types of computer arithmetic, all
*
constants are also provided in a normal decimal radix
* DESCRIPTION:
which one can hope are correctly converted to a suitable
*
format by the available C language compiler. To invoke
* This file contains definitions for error codes that are
this mode, the symbol UNK is defined.
* passed to the common error handling routine mtherr
* (which see).
An important difference among these modes is a predefined
*
set of machine arithmetic constants for each. The numbers
* The file also includes a conditional assembly definition
MACHEP (the machine roundoff error), MAXNUM (largest number
* for the type of computer arithmetic (Intel IEEE, DEC, Motorola
represented), and several other parameters are preset by
* IEEE, or UNKnown).
the configuration symbol. Check the file const.c to
*
ensure that these values are correct for your computer.
* For Digital Equipment PDP-11 and VAX computers, certain
* IBM systems, and others that use numbers with a 56-bit
For ANSI C compatibility, define ANSIC equal to 1. Currently
* significand, the symbol DEC should be defined. In this
this affects only the atan2 function and others that use it. */
* mode, most floating point constants are given as arrays
* of octal integers to eliminate decimal to binary conversion
* errors that might be introduced by the compiler.
*
* For computers, such as IBM PC, that follow the IEEE
* Standard for Binary Floating Point Arithmetic (ANSI/IEEE
* Std 754-1985), the symbol IBMPC or MIEEE should be defined.
* These numbers have 53-bit significands. In this mode, constants
* are provided as arrays of hexadecimal 16 bit integers.
*
* To accommodate other types of computer arithmetic, all
* constants are also provided in a normal decimal radix
* which one can hope are correctly converted to a suitable
* format by the available C language compiler. To invoke
* this mode, the symbol UNK is defined.
*
* An important difference among these modes is a predefined
* set of machine arithmetic constants for each. The numbers
* MACHEP (the machine roundoff error), MAXNUM (largest number
* represented), and several other parameters are preset by
* the configuration symbol. Check the file const.c to
* ensure that these values are correct for your computer.
*
* For ANSI C compatibility, define ANSIC equal to 1. Currently
* this affects only the atan2 function and others that use it.
*/
/* Constant definitions for math error conditions. */
/* Constant definitions for math error conditions. */
...
@@ -1345,20 +1320,12 @@ unsigned EMUSHORT epi[NE] =
...
@@ -1345,20 +1320,12 @@ unsigned EMUSHORT epi[NE] =
/* Control register for rounding precision.
/* Control register for rounding precision.
* This can be set to 113 (if NE=10), 80 (if NE=6), 64, 56, 53, or 24 bits.
This can be set to 113 (if NE=10), 80 (if NE=6), 64, 56, 53, or 24 bits. */
*/
int
rndprc
=
NBITS
;
int
rndprc
=
NBITS
;
extern
int
rndprc
;
extern
int
rndprc
;
static
void
toe24
(),
toe53
(),
toe64
(),
toe113
();
/* Clear out entire external format number. */
/*
; Clear out entire external format number.
;
; unsigned EMUSHORT x[];
; eclear (x);
*/
static
void
static
void
eclear
(
x
)
eclear
(
x
)
...
@@ -1372,10 +1339,7 @@ eclear (x)
...
@@ -1372,10 +1339,7 @@ eclear (x)
/* Move external format number from a to b.
/* Move external format number from a to b. */
*
* emov (a, b);
*/
static
void
static
void
emov
(
a
,
b
)
emov
(
a
,
b
)
...
@@ -1388,12 +1352,7 @@ emov (a, b)
...
@@ -1388,12 +1352,7 @@ emov (a, b)
}
}
/*
/* Absolute value of external format number. */
; Absolute value of external format number
;
; EMUSHORT x[NE];
; eabs (x);
*/
static
void
static
void
eabs
(
x
)
eabs
(
x
)
...
@@ -1403,15 +1362,7 @@ eabs (x)
...
@@ -1403,15 +1362,7 @@ eabs (x)
x
[
NE
-
1
]
&=
0x7fff
;
x
[
NE
-
1
]
&=
0x7fff
;
}
}
/* Negate external format number. */
/*
; Negate external format number
;
; unsigned EMUSHORT x[NE];
; eneg (x);
*/
static
void
static
void
eneg
(
x
)
eneg
(
x
)
...
@@ -1423,9 +1374,8 @@ eneg (x)
...
@@ -1423,9 +1374,8 @@ eneg (x)
/* Return 1 if sign bit of external format number is nonzero,
/* Return 1 if sign bit of external format number is nonzero, else zero. */
* else return zero.
*/
static
int
static
int
eisneg
(
x
)
eisneg
(
x
)
unsigned
EMUSHORT
x
[];
unsigned
EMUSHORT
x
[];
...
@@ -1438,9 +1388,7 @@ eisneg (x)
...
@@ -1438,9 +1388,7 @@ eisneg (x)
}
}
/* Return 1 if external format number is infinity.
/* Return 1 if external format number is infinity, else return zero. */
* else return zero.
*/
static
int
static
int
eisinf
(
x
)
eisinf
(
x
)
...
@@ -1458,27 +1406,27 @@ eisinf (x)
...
@@ -1458,27 +1406,27 @@ eisinf (x)
}
}
/* Check if e-type number is not a number.
/* Check if e-type number is not a number. The bit pattern is one that we
The bit pattern is one that we defined, so we know for sure how to
defined, so we know for sure how to detect it. */
detect it. */
static
int
static
int
eisnan
(
x
)
eisnan
(
x
)
unsigned
EMUSHORT
x
[];
unsigned
EMUSHORT
x
[];
{
{
#ifdef NANS
#ifdef NANS
int
i
;
int
i
;
/* NaN has maximum exponent */
/* NaN has maximum exponent */
if
((
x
[
NE
-
1
]
&
0x7fff
)
!=
0x7fff
)
if
((
x
[
NE
-
1
]
&
0x7fff
)
!=
0x7fff
)
return
(
0
);
return
(
0
);
/* ... and non-zero significand field. */
/* ... and non-zero significand field. */
for
(
i
=
0
;
i
<
NE
-
1
;
i
++
)
for
(
i
=
0
;
i
<
NE
-
1
;
i
++
)
{
{
if
(
*
x
++
!=
0
)
if
(
*
x
++
!=
0
)
return
(
1
);
return
(
1
);
}
}
#endif
#endif
return
(
0
);
return
(
0
);
}
}
...
@@ -1543,9 +1491,8 @@ enan (x, sign)
...
@@ -1543,9 +1491,8 @@ enan (x, sign)
}
}
/* Move in external format number,
/* Move in external format number, converting it to internal format. */
* converting it to internal format.
*/
static
void
static
void
emovi
(
a
,
b
)
emovi
(
a
,
b
)
unsigned
EMUSHORT
*
a
,
*
b
;
unsigned
EMUSHORT
*
a
,
*
b
;
...
@@ -1575,11 +1522,13 @@ emovi (a, b)
...
@@ -1575,11 +1522,13 @@ emovi (a, b)
return
;
return
;
}
}
#endif
#endif
for
(
i
=
2
;
i
<
NI
;
i
++
)
for
(
i
=
2
;
i
<
NI
;
i
++
)
*
q
++
=
0
;
*
q
++
=
0
;
return
;
return
;
}
}
#endif
#endif
/* clear high guard word */
/* clear high guard word */
*
q
++
=
0
;
*
q
++
=
0
;
/* move in the significand */
/* move in the significand */
...
@@ -1590,9 +1539,8 @@ emovi (a, b)
...
@@ -1590,9 +1539,8 @@ emovi (a, b)
}
}
/* Move internal format number out,
/* Move internal format number out, converting it to external format. */
* converting it to external format.
*/
static
void
static
void
emovo
(
a
,
b
)
emovo
(
a
,
b
)
unsigned
EMUSHORT
*
a
,
*
b
;
unsigned
EMUSHORT
*
a
,
*
b
;
...
@@ -1630,11 +1578,7 @@ emovo (a, b)
...
@@ -1630,11 +1578,7 @@ emovo (a, b)
*
q
--
=
*
p
++
;
*
q
--
=
*
p
++
;
}
}
/* Clear out internal format number. */
/* Clear out internal format number.
*/
static
void
static
void
ecleaz
(
xi
)
ecleaz
(
xi
)
...
@@ -1647,7 +1591,7 @@ ecleaz (xi)
...
@@ -1647,7 +1591,7 @@ ecleaz (xi)
}
}
/*
s
ame, but don't touch the sign. */
/*
S
ame, but don't touch the sign. */
static
void
static
void
ecleazs
(
xi
)
ecleazs
(
xi
)
...
@@ -1662,8 +1606,7 @@ ecleazs (xi)
...
@@ -1662,8 +1606,7 @@ ecleazs (xi)
/* Move internal format number from a to b.
/* Move internal format number from a to b. */
*/
static
void
static
void
emovz
(
a
,
b
)
emovz
(
a
,
b
)
...
@@ -1679,7 +1622,7 @@ emovz (a, b)
...
@@ -1679,7 +1622,7 @@ emovz (a, b)
/* Generate internal format NaN.
/* Generate internal format NaN.
The explicit pattern for this is maximum exponent and
The explicit pattern for this is maximum exponent and
top two significan
d
bits set. */
top two significan
t
bits set. */
static
void
static
void
einan
(
x
)
einan
(
x
)
...
@@ -1749,18 +1692,12 @@ eiisinf (x)
...
@@ -1749,18 +1692,12 @@ eiisinf (x)
}
}
/*
/* Compare significands of numbers in internal format.
; Compare significands of numbers in internal format.
Guard words are included in the comparison.
; Guard words are included in the comparison.
;
Returns +1 if a > b
; unsigned EMUSHORT a[NI], b[NI];
0 if a == b
; cmpm (a, b);
-1 if a < b */
;
; for the significands:
; returns +1 if a > b
; 0 if a == b
; -1 if a < b
*/
static
int
static
int
ecmpm
(
a
,
b
)
ecmpm
(
a
,
b
)
...
@@ -1785,9 +1722,7 @@ ecmpm (a, b)
...
@@ -1785,9 +1722,7 @@ ecmpm (a, b)
}
}
/*
/* Shift significand down by 1 bit. */
; Shift significand down by 1 bit
*/
static
void
static
void
eshdn1
(
x
)
eshdn1
(
x
)
...
@@ -1813,9 +1748,7 @@ eshdn1 (x)
...
@@ -1813,9 +1748,7 @@ eshdn1 (x)
/*
/* Shift significand up by 1 bit. */
; Shift significand up by 1 bit
*/
static
void
static
void
eshup1
(
x
)
eshup1
(
x
)
...
@@ -1840,10 +1773,7 @@ eshup1 (x)
...
@@ -1840,10 +1773,7 @@ eshup1 (x)
}
}
/* Shift significand down by 8 bits. */
/*
; Shift significand down by 8 bits
*/
static
void
static
void
eshdn8
(
x
)
eshdn8
(
x
)
...
@@ -1864,9 +1794,7 @@ eshdn8 (x)
...
@@ -1864,9 +1794,7 @@ eshdn8 (x)
}
}
}
}
/*
/* Shift significand up by 8 bits. */
; Shift significand up by 8 bits
*/
static
void
static
void
eshup8
(
x
)
eshup8
(
x
)
...
@@ -1888,9 +1816,7 @@ eshup8 (x)
...
@@ -1888,9 +1816,7 @@ eshup8 (x)
}
}
}
}
/*
/* Shift significand up by 16 bits. */
; Shift significand up by 16 bits
*/
static
void
static
void
eshup6
(
x
)
eshup6
(
x
)
...
@@ -1908,9 +1834,7 @@ eshup6 (x)
...
@@ -1908,9 +1834,7 @@ eshup6 (x)
*
p
=
0
;
*
p
=
0
;
}
}
/*
/* Shift significand down by 16 bits. */
; Shift significand down by 16 bits
*/
static
void
static
void
eshdn6
(
x
)
eshdn6
(
x
)
...
@@ -1928,10 +1852,7 @@ eshdn6 (x)
...
@@ -1928,10 +1852,7 @@ eshdn6 (x)
*
(
--
p
)
=
0
;
*
(
--
p
)
=
0
;
}
}
/*
/* Add significands. x + y replaces y. */
; Add significands
; x + y replaces y
*/
static
void
static
void
eaddm
(
x
,
y
)
eaddm
(
x
,
y
)
...
@@ -1957,10 +1878,7 @@ eaddm (x, y)
...
@@ -1957,10 +1878,7 @@ eaddm (x, y)
}
}
}
}
/*
/* Subtract significands. y - x replaces y. */
; Subtract significands
; y - x replaces y
*/
static
void
static
void
esubm
(
x
,
y
)
esubm
(
x
,
y
)
...
@@ -2013,9 +1931,9 @@ edivm (den, num)
...
@@ -2013,9 +1931,9 @@ edivm (den, num)
*p++ = 0;
*p++ = 0;
}
}
/* Use faster compare and subtraction if denominator
/* Use faster compare and subtraction if denominator
has only 15 bits of
* has only 15 bits of significance.
significance. */
*/
p = &den[M + 2];
p = &den[M + 2];
if (*p++ == 0)
if (*p++ == 0)
{
{
...
@@ -2050,9 +1968,9 @@ edivm (den, num)
...
@@ -2050,9 +1968,9 @@ edivm (den, num)
goto divdon;
goto divdon;
}
}
/* The number of quotient bits to calculate is
/* The number of quotient bits to calculate is
NBITS + 1 scaling guard
* NBITS + 1 scaling guard bit + 1 roundoff bit.
bit + 1 roundoff bit. */
*/
fulldiv:
fulldiv:
p = &equot[NI - 2];
p = &equot[NI - 2];
...
@@ -2107,7 +2025,7 @@ emulm (a, b)
...
@@ -2107,7 +2025,7 @@ emulm (a, b)
p = &a[NI - 2];
p = &a[NI - 2];
k = NBITS;
k = NBITS;
while (*p == 0) /* significand is not supposed to be
all
zero */
while (*p == 0) /* significand is not supposed to be zero */
{
{
eshdn6 (a);
eshdn6 (a);
k -= 16;
k -= 16;
...
@@ -2297,25 +2215,23 @@ emulm (a, b)
...
@@ -2297,25 +2215,23 @@ emulm (a, b)
#endif
#endif
/*
/* Normalize and round off.
* Normalize and round off.
*
* The internal format number to be rounded is "s".
* Input "lost" indicates whether or not the number is exact.
* This is the so-called sticky bit.
*
* Input "subflg" indicates whether the number was obtained
* by a subtraction operation. In that case if lost is nonzero
* then the number is slightly smaller than indicated.
*
* Input "exp" is the biased exponent, which may be negative.
* the exponent field of "s" is ignored but is replaced by
* "exp" as adjusted by normalization and rounding.
*
* Input "rcntrl" is the rounding control.
*/
/* For future reference: In order for emdnorm to round off denormal
The internal format number to be rounded is "s".
Input "lost" indicates whether or not the number is exact.
This is the so-called sticky bit.
Input "subflg" indicates whether the number was obtained
by a subtraction operation. In that case if lost is nonzero
then the number is slightly smaller than indicated.
Input "exp" is the biased exponent, which may be negative.
the exponent field of "s" is ignored but is replaced by
"exp" as adjusted by normalization and rounding.
Input "rcntrl" is the rounding control.
For future reference: In order for emdnorm to round off denormal
significands at the right point, the input exponent must be
significands at the right point, the input exponent must be
adjusted to be the actual value it would have after conversion to
adjusted to be the actual value it would have after conversion to
the final floating point type. This adjustment has been
the final floating point type. This adjustment has been
...
@@ -2528,12 +2444,7 @@ emdnorm (s, lost, subflg, exp, rcntrl)
...
@@ -2528,12 +2444,7 @@ emdnorm (s, lost, subflg, exp, rcntrl)
/*
/* Subtract external format numbers. */
; Subtract external format numbers.
;
; unsigned EMUSHORT a[NE], b[NE], c[NE];
; esub (a, b, c); c = b - a
*/
static
int
subflg
=
0
;
static
int
subflg
=
0
;
...
@@ -2568,12 +2479,7 @@ esub (a, b, c)
...
@@ -2568,12 +2479,7 @@ esub (a, b, c)
}
}
/*
/* Add. */
; Add.
;
; unsigned EMUSHORT a[NE], b[NE], c[NE];
; eadd (a, b, c); c = b + a
*/
static
void
static
void
eadd
(
a
,
b
,
c
)
eadd
(
a
,
b
,
c
)
...
@@ -2710,12 +2616,7 @@ eadd1 (a, b, c)
...
@@ -2710,12 +2616,7 @@ eadd1 (a, b, c)
/*
/* Divide. */
; Divide.
;
; unsigned EMUSHORT a[NE], b[NE], c[NE];
; ediv (a, b, c); c = b / a
*/
static
void
static
void
ediv
(
a
,
b
,
c
)
ediv
(
a
,
b
,
c
)
...
@@ -2819,12 +2720,7 @@ ediv (a, b, c)
...
@@ -2819,12 +2720,7 @@ ediv (a, b, c)
/*
/* Multiply. */
; Multiply.
;
; unsigned EMUSHORT a[NE], b[NE], c[NE];
; emul (a, b, c); c = b * a
*/
static
void
static
void
emul
(
a
,
b
,
c
)
emul
(
a
,
b
,
c
)
...
@@ -2917,12 +2813,7 @@ emul (a, b, c)
...
@@ -2917,12 +2813,7 @@ emul (a, b, c)
/*
/* Convert IEEE double precision to e type. */
; Convert IEEE double precision to e type
; double d;
; unsigned EMUSHORT x[N+2];
; e53toe (&d, x);
*/
static
void
static
void
e53toe
(
pe
,
y
)
e53toe
(
pe
,
y
)
...
@@ -2984,7 +2875,8 @@ e53toe (pe, y)
...
@@ -2984,7 +2875,8 @@ e53toe (pe, y)
#endif
/* INFINITY */
#endif
/* INFINITY */
r
>>=
4
;
r
>>=
4
;
/* If zero exponent, then the significand is denormalized.
/* If zero exponent, then the significand is denormalized.
* So, take back the understood high significand bit. */
So take back the understood high significand bit. */
if
(
r
==
0
)
if
(
r
==
0
)
{
{
denorm
=
1
;
denorm
=
1
;
...
@@ -3166,12 +3058,7 @@ e113toe (pe, y)
...
@@ -3166,12 +3058,7 @@ e113toe (pe, y)
}
}
/*
/* Convert IEEE single precision to e type. */
; Convert IEEE single precision to e type
; float d;
; unsigned EMUSHORT x[N+2];
; dtox (&d, x);
*/
static
void
static
void
e24toe
(
pe
,
y
)
e24toe
(
pe
,
y
)
...
@@ -3229,7 +3116,7 @@ e24toe (pe, y)
...
@@ -3229,7 +3116,7 @@ e24toe (pe, y)
#endif
/* INFINITY */
#endif
/* INFINITY */
r
>>=
7
;
r
>>=
7
;
/* If zero exponent, then the significand is denormalized.
/* If zero exponent, then the significand is denormalized.
* So,
take back the understood high significand bit. */
So
take back the understood high significand bit. */
if
(
r
==
0
)
if
(
r
==
0
)
{
{
denorm
=
1
;
denorm
=
1
;
...
@@ -3291,7 +3178,7 @@ etoe113 (x, e)
...
@@ -3291,7 +3178,7 @@ etoe113 (x, e)
toe113
(
xi
,
e
);
toe113
(
xi
,
e
);
}
}
/*
m
ove out internal format to ieee long double */
/*
M
ove out internal format to ieee long double */
static
void
static
void
toe113
(
a
,
b
)
toe113
(
a
,
b
)
...
@@ -3376,7 +3263,8 @@ etoe64 (x, e)
...
@@ -3376,7 +3263,8 @@ etoe64 (x, e)
}
}
/* move out internal format to ieee long double */
/* Move out internal format to ieee long double. */
static
void
static
void
toe64
(
a
,
b
)
toe64
(
a
,
b
)
unsigned
EMUSHORT
*
a
,
*
b
;
unsigned
EMUSHORT
*
a
,
*
b
;
...
@@ -3429,12 +3317,7 @@ toe64 (a, b)
...
@@ -3429,12 +3317,7 @@ toe64 (a, b)
}
}
/*
/* e type to IEEE double precision. */
; e type to IEEE double precision
; double d;
; unsigned EMUSHORT x[NE];
; etoe53 (x, &d);
*/
#ifdef DEC
#ifdef DEC
...
@@ -3586,12 +3469,8 @@ toe53 (x, y)
...
@@ -3586,12 +3469,8 @@ toe53 (x, y)
/*
/* e type to IEEE single precision. */
; e type to IEEE single precision
; float d;
; unsigned EMUSHORT x[N+2];
; xtod (x, &d);
*/
#ifdef IBM
#ifdef IBM
void
void
...
@@ -3725,15 +3604,10 @@ toe24 (x, y)
...
@@ -3725,15 +3604,10 @@ toe24 (x, y)
#endif
/* not IBM */
#endif
/* not IBM */
/* Compare two e type numbers.
/* Compare two e type numbers.
*
Return +1 if a > b
* unsigned EMUSHORT a[NE], b[NE];
0 if a == b
* ecmp (a, b);
-1 if a < b
*
-2 if either a or b is a NaN. */
* returns +1 if a > b
* 0 if a == b
* -1 if a < b
* -2 if either a or b is a NaN.
*/
static
int
static
int
ecmp
(
a
,
b
)
ecmp
(
a
,
b
)
...
@@ -3800,11 +3674,7 @@ ecmp (a, b)
...
@@ -3800,11 +3674,7 @@ ecmp (a, b)
/* Find nearest integer to x = floor (x + 0.5)
/* Find nearest integer to x = floor (x + 0.5). */
*
* unsigned EMUSHORT x[NE], y[NE]
* eround (x, y);
*/
static
void
static
void
eround
(
x
,
y
)
eround
(
x
,
y
)
...
@@ -3817,14 +3687,7 @@ eround (x, y)
...
@@ -3817,14 +3687,7 @@ eround (x, y)
/*
/* Convert HOST_WIDE_INT to e type. */
; convert HOST_WIDE_INT to e type
;
; HOST_WIDE_INT l;
; unsigned EMUSHORT x[NE];
; ltoe (&l, x);
; note &l is the memory address of l
*/
static
void
static
void
ltoe
(
lp
,
y
)
ltoe
(
lp
,
y
)
...
@@ -3866,14 +3729,7 @@ ltoe (lp, y)
...
@@ -3866,14 +3729,7 @@ ltoe (lp, y)
emovo
(
yi
,
y
);
/* output the answer */
emovo
(
yi
,
y
);
/* output the answer */
}
}
/*
/* Convert unsigned HOST_WIDE_INT to e type. */
; convert unsigned HOST_WIDE_INT to e type
;
; unsigned HOST_WIDE_INT l;
; unsigned EMUSHORT x[NE];
; ltox (&l, x);
; note &l is the memory address of l
*/
static
void
static
void
ultoe
(
lp
,
y
)
ultoe
(
lp
,
y
)
...
@@ -4067,12 +3923,7 @@ euifrac (x, i, frac)
...
@@ -4067,12 +3923,7 @@ euifrac (x, i, frac)
/*
/* Shift significand area up or down by the number of bits given by SC. */
; Shift significand
;
; Shifts significand area up or down by the number of bits
; given by the variable sc.
*/
static
int
static
int
eshift
(
x
,
sc
)
eshift
(
x
,
sc
)
...
@@ -4139,12 +3990,8 @@ eshift (x, sc)
...
@@ -4139,12 +3990,8 @@ eshift (x, sc)
/*
/* Shift normalize the significand area pointed to by argument.
; normalize
Shift count (up = positive) is returned. */
;
; Shift normalizes the significand area pointed to by argument
; shift count (up = positive) is returned.
*/
static
int
static
int
enormlz
(
x
)
enormlz
(
x
)
...
@@ -4164,9 +4011,9 @@ enormlz (x)
...
@@ -4164,9 +4011,9 @@ enormlz (x)
{
{
eshup6
(
x
);
eshup6
(
x
);
sc
+=
16
;
sc
+=
16
;
/* With guard word, there are NBITS+16 bits available.
/* With guard word, there are NBITS+16 bits available.
* return true if all are zero.
Return true if all are zero. */
*/
if
(
sc
>
NBITS
)
if
(
sc
>
NBITS
)
return
(
sc
);
return
(
sc
);
}
}
...
@@ -4216,8 +4063,7 @@ enormlz (x)
...
@@ -4216,8 +4063,7 @@ enormlz (x)
/* Convert e type number to decimal format ASCII string.
/* Convert e type number to decimal format ASCII string.
* The constants are for 64 bit precision.
The constants are for 64 bit precision. */
*/
#define NTEN 12
#define NTEN 12
#define MAXP 4096
#define MAXP 4096
...
@@ -4679,26 +4525,13 @@ etoasc (x, string, ndigs)
...
@@ -4679,26 +4525,13 @@ etoasc (x, string, ndigs)
}
}
/* Convert ASCII string to quadruple precision floating point
Numeric input is free field decimal number with max of 15 digits with or
/*
without decimal point entered as ASCII from teletype. Entering E after
; ASCTOQ
the number followed by a second number causes the second number to be
; ASCTOQ.MAC LATEST REV: 11 JAN 84
interpreted as a power of 10 to be multiplied by the first number
; SLM, 3 JAN 78
(i.e., "scientific" notation). */
;
; Convert ASCII string to quadruple precision floating point
;
; Numeric input is free field decimal number
; with max of 15 digits with or without
; decimal point entered as ASCII from teletype.
; Entering E after the number followed by a second
; number causes the second number to be interpreted
; as a power of 10 to be multiplied by the first number
; (i.e., "scientific" notation).
;
; Usage:
; asctoq (string, q);
*/
/* ASCII to single */
/* ASCII to single */
...
@@ -4747,6 +4580,7 @@ asctoe113 (s, y)
...
@@ -4747,6 +4580,7 @@ asctoe113 (s, y)
}
}
/* ASCII to super double */
/* ASCII to super double */
static
void
static
void
asctoe
(
s
,
y
)
asctoe
(
s
,
y
)
char
*
s
;
char
*
s
;
...
@@ -4757,6 +4591,7 @@ asctoe (s, y)
...
@@ -4757,6 +4591,7 @@ asctoe (s, y)
/* ASCII to e type, with specified rounding precision = oprec. */
/* ASCII to e type, with specified rounding precision = oprec. */
static
void
static
void
asctoeg
(
ss
,
y
,
oprec
)
asctoeg
(
ss
,
y
,
oprec
)
char
*
ss
;
char
*
ss
;
...
@@ -4818,11 +4653,12 @@ asctoeg (ss, y, oprec)
...
@@ -4818,11 +4653,12 @@ asctoeg (ss, y, oprec)
if
(
*
s
==
'z'
)
if
(
*
s
==
'z'
)
goto
donchr
;
goto
donchr
;
}
}
/* If enough digits were given to more than fill up the yy register,
/* If enough digits were given to more than fill up the yy register,
*
continuing until overflow into the high guard word yy[2]
continuing until overflow into the high guard word yy[2]
*
guarantees that there will be a roundoff bit at the top
guarantees that there will be a roundoff bit at the top
* of the low guard word after normalization.
of the low guard word after normalization. */
*/
if
(
yy
[
2
]
==
0
)
if
(
yy
[
2
]
==
0
)
{
{
if
(
decflg
)
if
(
decflg
)
...
@@ -4958,15 +4794,15 @@ asctoeg (ss, y, oprec)
...
@@ -4958,15 +4794,15 @@ asctoeg (ss, y, oprec)
}
}
lexp
=
(
EXONE
-
1
+
NBITS
)
-
k
;
lexp
=
(
EXONE
-
1
+
NBITS
)
-
k
;
emdnorm
(
yy
,
lost
,
0
,
lexp
,
64
);
emdnorm
(
yy
,
lost
,
0
,
lexp
,
64
);
/* convert to external format */
/* Convert to external format:
Multiply by 10**nexp. If precision is 64 bits,
the maximum relative error incurred in forming 10**n
for 0 <= n <= 324 is 8.2e-20, at 10**180.
For 0 <= n <= 999, the peak relative error is 1.4e-19 at 10**947.
For 0 >= n >= -999, it is -1.55e-19 at 10**-435. */
/* Multiply by 10**nexp. If precision is 64 bits,
* the maximum relative error incurred in forming 10**n
* for 0 <= n <= 324 is 8.2e-20, at 10**180.
* For 0 <= n <= 999, the peak relative error is 1.4e-19 at 10**947.
* For 0 >= n >= -999, it is -1.55e-19 at 10**-435.
*/
lexp
=
yy
[
E
];
lexp
=
yy
[
E
];
if
(
nexp
==
0
)
if
(
nexp
==
0
)
{
{
...
@@ -4979,7 +4815,8 @@ asctoeg (ss, y, oprec)
...
@@ -4979,7 +4815,8 @@ asctoeg (ss, y, oprec)
nexp
=
-
nexp
;
nexp
=
-
nexp
;
esign
=
-
1
;
esign
=
-
1
;
if
(
nexp
>
4096
)
if
(
nexp
>
4096
)
{
/* Punt. Can't handle this without 2 divides. */
{
/* Punt. Can't handle this without 2 divides. */
emovi
(
etens
[
0
],
tt
);
emovi
(
etens
[
0
],
tt
);
lexp
-=
tt
[
E
];
lexp
-=
tt
[
E
];
k
=
edivm
(
tt
,
yy
);
k
=
edivm
(
tt
,
yy
);
...
@@ -5068,13 +4905,8 @@ asctoeg (ss, y, oprec)
...
@@ -5068,13 +4905,8 @@ asctoeg (ss, y, oprec)
/* y = largest integer not greater than x
/* y = largest integer not greater than x (truncated toward minus infinity) */
* (truncated toward minus infinity)
*
* unsigned EMUSHORT x[NE], y[NE]
*
* efloor (x, y);
*/
static
unsigned
EMUSHORT
bmask
[]
=
static
unsigned
EMUSHORT
bmask
[]
=
{
{
0xffff
,
0xffff
,
...
@@ -5143,15 +4975,9 @@ efloor (x, y)
...
@@ -5143,15 +4975,9 @@ efloor (x, y)
}
}
/* unsigned EMUSHORT x[], s[];
/* Returns s and exp such that s * 2**exp = x and .5 <= s < 1.
* int *exp;
For example, 1.1 = 0.55 * 2**1
*
Handles denormalized numbers properly using long integer exp. */
* efrexp (x, exp, s);
*
* Returns s and exp such that s * 2**exp = x and .5 <= s < 1.
* For example, 1.1 = 0.55 * 2**1
* Handles denormalized numbers properly using long integer exp.
*/
static
void
static
void
efrexp
(
x
,
exp
,
s
)
efrexp
(
x
,
exp
,
s
)
...
@@ -5176,13 +5002,7 @@ efrexp (x, exp, s)
...
@@ -5176,13 +5002,7 @@ efrexp (x, exp, s)
/* unsigned EMUSHORT x[], y[];
/* Return y = x * 2**pwr2. */
* int pwr2;
*
* eldexp (x, pwr2, y);
*
* Returns y = x * 2**pwr2.
*/
static
void
static
void
eldexp
(
x
,
pwr2
,
y
)
eldexp
(
x
,
pwr2
,
y
)
...
@@ -5204,8 +5024,7 @@ eldexp (x, pwr2, y)
...
@@ -5204,8 +5024,7 @@ eldexp (x, pwr2, y)
/* c = remainder after dividing b by a
/* c = remainder after dividing b by a
* Least significant integer quotient bits left in equot[].
Least significant integer quotient bits left in equot[]. */
*/
static
void
static
void
eremain
(
a
,
b
,
c
)
eremain
(
a
,
b
,
c
)
...
@@ -5271,69 +5090,36 @@ eiremain (den, num)
...
@@ -5271,69 +5090,36 @@ eiremain (den, num)
emdnorm
(
num
,
0
,
0
,
ln
,
0
);
emdnorm
(
num
,
0
,
0
,
ln
,
0
);
}
}
/* mtherr.c
/* This routine may be called to report one of the following
*
error conditions (in the include file mconf.h).
* Library common error handling routine
*
*
*
* SYNOPSIS:
*
* char *fctnam;
* int code;
* void mtherr ();
*
* mtherr (fctnam, code);
*
*
*
* DESCRIPTION:
*
* This routine may be called to report one of the following
* error conditions (in the include file mconf.h).
*
* Mnemonic Value Significance
*
* DOMAIN 1 argument domain error
* SING 2 function singularity
* OVERFLOW 3 overflow range error
* UNDERFLOW 4 underflow range error
* TLOSS 5 total loss of precision
* PLOSS 6 partial loss of precision
* INVALID 7 NaN - producing operation
* EDOM 33 Unix domain error code
* ERANGE 34 Unix range error code
*
* The default version of the file prints the function name,
* passed to it by the pointer fctnam, followed by the
* error condition. The display is directed to the standard
* output device. The routine then returns to the calling
* program. Users may wish to modify the program to abort by
* calling exit under severe error conditions such as domain
* errors.
*
* Since all error conditions pass control to this function,
* the display may be easily changed, eliminated, or directed
* to an error logging device.
*
* SEE ALSO:
*
* mconf.h
*
*/
/*
Mnemonic Value Significance
Cephes Math Library Release 2.0: April, 1987
Copyright 1984, 1987 by Stephen L. Moshier
Direct inquiries to 30 Frost Street, Cambridge, MA 02140
*/
/* include "mconf.h" */
DOMAIN 1 argument domain error
SING 2 function singularity
OVERFLOW 3 overflow range error
UNDERFLOW 4 underflow range error
TLOSS 5 total loss of precision
PLOSS 6 partial loss of precision
INVALID 7 NaN - producing operation
EDOM 33 Unix domain error code
ERANGE 34 Unix range error code
The default version of the file prints the function name,
passed to it by the pointer fctnam, followed by the
error condition. The display is directed to the standard
output device. The routine then returns to the calling
program. Users may wish to modify the program to abort by
calling exit under severe error conditions such as domain
errors.
Since all error conditions pass control to this function,
the display may be easily changed, eliminated, or directed
to an error logging device. */
/* Note: the order of appearance of the following messages is bound to the
error codes defined above. */
/* Notice: the order of appearance of the following
* messages is bound to the error codes defined
* in mconf.h.
*/
#define NMSGS 8
#define NMSGS 8
static
char
*
ermsg
[
NMSGS
]
=
static
char
*
ermsg
[
NMSGS
]
=
{
{
...
@@ -5357,14 +5143,11 @@ mtherr (name, code)
...
@@ -5357,14 +5143,11 @@ mtherr (name, code)
{
{
char
errstr
[
80
];
char
errstr
[
80
];
/* Display string passed by calling program,
/* Display string passed by calling program,
which is supposed to be the
* which is supposed to be the name of the
name of the function in which the error occurred.
* function in which the error occurred.
*/
Display error message defined by the code argument.
*/
/* Display error message defined
* by the code argument.
*/
if
((
code
<=
0
)
||
(
code
>=
NMSGS
))
if
((
code
<=
0
)
||
(
code
>=
NMSGS
))
code
=
0
;
code
=
0
;
sprintf
(
errstr
,
" %s %s error"
,
name
,
ermsg
[
code
]);
sprintf
(
errstr
,
" %s %s error"
,
name
,
ermsg
[
code
]);
...
@@ -5372,23 +5155,10 @@ mtherr (name, code)
...
@@ -5372,23 +5155,10 @@ mtherr (name, code)
warning
(
errstr
);
warning
(
errstr
);
/* Set global error message word */
/* Set global error message word */
merror
=
code
+
1
;
merror
=
code
+
1
;
/* Return to calling
* program
*/
}
}
#ifdef DEC
#ifdef DEC
/* Here is etodec.c .
/* Convert DEC double precision to e type. */
*
*/
/*
; convert DEC double precision to e type
; double d;
; EMUSHORT e[NE];
; dectoe (&d, e);
*/
static
void
static
void
dectoe
(
d
,
e
)
dectoe
(
d
,
e
)
...
@@ -5499,17 +5269,7 @@ todec (x, y)
...
@@ -5499,17 +5269,7 @@ todec (x, y)
#endif
/* DEC */
#endif
/* DEC */
#ifdef IBM
#ifdef IBM
/* Here is etoibm
/* Convert IBM single/double precision to e type. */
*
*/
/*
; convert IBM single/double precision to e type
; single/double d;
; EMUSHORT e[NE];
; enum machine_mode mode; SFmode/DFmode
; ibmtoe (&d, e, mode);
*/
static
void
static
void
ibmtoe
(
d
,
e
,
mode
)
ibmtoe
(
d
,
e
,
mode
)
...
@@ -5553,13 +5313,7 @@ ibmtoe (d, e, mode)
...
@@ -5553,13 +5313,7 @@ ibmtoe (d, e, mode)
/*
/* Convert e type to IBM single/double precision. */
; convert e type to IBM single/double precision
; single/double d;
; EMUSHORT e[NE];
; enum machine_mode mode; SFmode/DFmode
; etoibm (e, &d, mode);
*/
static
void
static
void
etoibm
(
x
,
d
,
mode
)
etoibm
(
x
,
d
,
mode
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment