IEEE(3) BSD Programmer's Manual IEEE(3)
c
\bco
\bop
\bpy
\bys
\bsi
\big
\bgn
\bn, d
\bdr
\bre
\bem
\bm, f
\bfi
\bin
\bni
\bit
\bte
\be, l
\blo
\bog
\bgb
\bb, s
\bsc
\bca
\bal
\blb
\bb - IEEE 754 floating point support
S
\bSY
\bYN
\bNO
\bOP
\bPS
\bSI
\bIS
\bS
#
\b#i
\bin
\bnc
\bcl
\blu
\bud
\bde
\be <
\b<m
\bma
\bat
\bth
\bh.
\b.h
\bh>
\b>
c
\bco
\bop
\bpy
\bys
\bsi
\big
\bgn
\bn(_
\bd_
\bo_
\bu_
\bb_
\bl_
\be _
\bx, _
\bd_
\bo_
\bu_
\bb_
\bl_
\be _
\by);
d
\bdr
\bre
\bem
\bm(_
\bd_
\bo_
\bu_
\bb_
\bl_
\be _
\bx, _
\bd_
\bo_
\bu_
\bb_
\bl_
\be _
\by);
f
\bfi
\bin
\bni
\bit
\bte
\be(_
\bd_
\bo_
\bu_
\bb_
\bl_
\be _
\bx);
l
\blo
\bog
\bgb
\bb(_
\bd_
\bo_
\bu_
\bb_
\bl_
\be _
\bx);
s
\bsc
\bca
\bal
\blb
\bb(_
\bd_
\bo_
\bu_
\bb_
\bl_
\be _
\bx, _
\bi_
\bn_
\bt _
\bn);
D
\bDE
\bES
\bSC
\bCR
\bRI
\bIP
\bPT
\bTI
\bIO
\bON
\bN
These functions are required for, or recommended by the IEEE standard 754
for floating-point arithmetic.
The c
\bco
\bop
\bpy
\bys
\bsi
\big
\bgn
\bn() function returns _
\bx with its sign changed to _
\by's.
The d
\bdr
\bre
\bem
\bm() function returns the remainder _
\br := _
\bx - _
\bn_
\b*_
\by where _
\bn is the in-
teger nearest the exact value of _
\bx/_
\by; moreover if |_
\bn - _
\bx/_
\by| = 1/2 then _
\bn
is even. Consequently the remainder is computed exactly and |_
\br| <=
|_
\by|/2. But d
\bdr
\bre
\bem
\bm(_
\bx, _
\b0) is exceptional. (See below under _
\bD_
\bI_
\bA_
\bG_
\bN_
\bO_
\bS_
\bT_
\bI_
\bC_
\bS.)
The f
\bfi
\bin
\bni
\bit
\bte
\be() function returns the value 1 just when -infinity < _
\bx < +in-
finity; otherwise a zero is returned (when |_
\bx| = infinity or _
\bx is _
\bN_
\ba_
\bN or
is the VAX's reserved operand).
The l
\blo
\bog
\bgb
\bb() function returns _
\bx's exponent _
\bn, a signed integer converted to
double-precision floating-point and so chosen that 1 (<= |_
\bx|2**_
\bn < 2 un-
less _
\bx = 0 or (only on machines that conform to IEEE 754) |_
\bx| = infinity
or _
\bx lies between 0 and the Underflow Threshold. (See below under _
\bB_
\bU_
\bG_
\bS.)
The s
\bsc
\bca
\bal
\blb
\bb() function returns _
\bx*(2**_
\bn) computed, for integer n, without
R
\bRE
\bET
\bTU
\bUR
\bRN
\bN V
\bVA
\bAL
\bLU
\bUE
\bES
\bS
The IEEE standard 754 defines d
\bdr
\bre
\bem
\bm(_
\bx, _
\b0) and d
\bdr
\bre
\bem
\bm(_
\bi_
\bn_
\bf_
\bi_
\bn_
\bi_
\bt_
\by, _
\by) to be in-
valid operations that produce a _
\bN_
\ba_
\bN. On the VAX, d
\bdr
\bre
\bem
\bm(_
\bx, _
\b0) generates a
reserved operand fault. No infinity exists on a VAX.
IEEE 754 defines l
\blo
\bog
\bgb
\bb(_
\b+_
\b-_
\bi_
\bn_
\bf_
\bi_
\bn_
\bi_
\bt_
\by) = infinity and l
\blo
\bog
\bgb
\bb(_
\b0) = -infinity, and
requires the latter to signal Division-by-Zero. But on a VAX, l
\blo
\bog
\bgb
\bb(_
\b0) =
1.0 - 2.0**31 = -2,147,483,647.0. And if the correct value of s
\bsc
\bca
\bal
\blb
\bb()
would overflow on a VAX, it generates a reserved operand fault and sets
the global variable _
\be_
\br_
\br_
\bn_
\bo to ERANGE.
S
\bSE
\bEE
\bE A
\bAL
\bLS
\bSO
\bO
floor(3), math(3), infnan(3)
H
\bHI
\bIS
\bST
\bTO
\bOR
\bRY
\bY
The i
\bie
\bee
\bee
\be functions appeared in 4.3BSD.
Should d
\bdr
\bre
\bem
\bm(_
\bx, _
\b0) and l
\blo
\bog
\bgb
\bb(_
\b0) on a VAX signal invalidity by setting _
\be_
\br_
\br_
\bn_
\bo
= EDOM ? Should l
\blo
\bog
\bgb
\bb(_
\b0) return -1.7e38?
IEEE 754 currently specifies that l
\blo
\bog
\bgb
\bb(_
\bd_
\be_
\bn_
\bo_
\br_
\bm_
\ba_
\bl_
\bi_
\bz_
\be_
\bd _
\bn_
\bo_
\b.) = l
\blo
\bog
\bgb
\bb(_
\bt_
\bi_
\bn_
\bi_
\be_
\bs_
\bt
_
\bn_
\bo_
\br_
\bm_
\ba_
\bl_
\bi_
\bz_
\be_
\bd _
\bn_
\bo_
\b. _
\b> _
\b0) but the consensus has changed to the specification in
the new proposed IEEE standard p854, namely that l
\blo
\bog
\bgb
\bb(_
\bx) satisfy
1 <= s
\bsc
\bca
\bal
\blb
\bb(|_
\bx|, _
\b-_
\bl_
\bo_
\bg_
\bb_
\b(_
\bx_
\b)) < Radix ... = 2 for IEEE 754
for every x except 0, infinity and _
\bN_
\ba_
\bN. Almost every program that as-
sumes 754's specification will work correctly if l
\blo
\bog
\bgb
\bb() follows 854's
IEEE 754 requires c
\bco
\bop
\bpy
\bys
\bsi
\big
\bgn
\bn(_
\bx, _
\bN_
\ba_
\bN_
\b)) = +-_
\bx but says nothing else about the
sign of a _
\bN_
\ba_
\bN. A _
\bN_
\ba_
\bN _
\b(_
\bNot _
\ba _
\bNumber) is similar in spirit to the VAX's
reserved operand, but very different in important details. Since the
sign bit of a reserved operand makes it look negative,
c
\bco
\bop
\bpy
\bys
\bsi
\big
\bgn
\bn(_
\bx, _
\br_
\be_
\bs_
\be_
\br_
\bv_
\be_
\bd _
\bo_
\bp_
\be_
\br_
\ba_
\bn_
\bd) = -_
\bx;
should this return the reserved operand instead?
4.3 Berkeley Distribution June 4, 1993 2