|
|
1.1 ! root 1: .\" Copyright (c) 1985 Regents of the University of California. ! 2: .\" All rights reserved. The Berkeley software License Agreement ! 3: .\" specifies the terms and conditions for redistribution. ! 4: .\" ! 5: .\" @(#)ieee.3 6.2 (Berkeley) 5/12/86 ! 6: .\" ! 7: .TH IEEE 3M "May 12, 1986" ! 8: .UC 6 ! 9: .ds nn \fINaN\fR ! 10: .SH NAME ! 11: copysign, drem, finite, logb, scalb \- copysign, remainder, ! 12: exponent manipulations ! 13: .SH SYNOPSIS ! 14: .nf ! 15: .B #include <math.h> ! 16: .PP ! 17: .B double copysign(x,y) ! 18: .B double x,y; ! 19: .PP ! 20: .B double drem(x,y) ! 21: .B double x,y; ! 22: .PP ! 23: .B int finite(x) ! 24: .B double x; ! 25: .PP ! 26: .B double logb(x) ! 27: .B double x; ! 28: .PP ! 29: .B double scalb(x,n) ! 30: .B double x; ! 31: .B int n; ! 32: .fi ! 33: .SH DESCRIPTION ! 34: These functions are required for, or recommended by the IEEE standard ! 35: 754 for floating\-point arithmetic. ! 36: .PP ! 37: Copysign(x,y) ! 38: returns x with its sign changed to y's. ! 39: .PP ! 40: Drem(x,y) returns the remainder r := x \- n\(**y ! 41: where n is the integer nearest the exact value of x/y; ! 42: moreover if |n\|\-\|x/y|\|=\|1/2 then n is even. Consequently ! 43: the remainder is computed exactly and |r| \(<= |y|/2. But ! 44: drem(x,0) is exceptional; see below under DIAGNOSTICS. ! 45: .PP ! 46: .nf ! 47: .ta \w'Finite(x)'u+1n +\w'= 0 otherwise'u+1n ! 48: .if n \ ! 49: Finite(x) = 1 just when \-infinity < x < +infinity, ! 50: .if t \ ! 51: Finite(x) = 1 just when \-\(if < x < +\(if, ! 52: .if n \ ! 53: = 0 otherwise (when |x| = infinity or x is \*(nn or ! 54: .if t \ ! 55: = 0 otherwise (when |x| = \(if or x is \*(nn or ! 56: \0x is the VAX's reserved operand.) ! 57: .ta ! 58: .fi ! 59: .PP ! 60: Logb(x) returns x's exponent n, ! 61: a signed integer converted to double\-precision floating\-point and so ! 62: chosen that 1\0\(<=\0|x|/2**n\0<\02 unless x = 0 or ! 63: (only on machines that conform to IEEE 754) ! 64: .if n \ ! 65: |x| = infinity ! 66: .if t \ ! 67: |x| = \(if ! 68: or x lies between 0 and the Underflow Threshold; see below under "BUGS". ! 69: .PP ! 70: Scalb(x,n) = x\(**(2**n) computed, for integer n, without first computing ! 71: 2**n. ! 72: .SH DIAGNOSTICS ! 73: IEEE 754 defines drem(x,0) and ! 74: .if n \ ! 75: drem(infinity,y) ! 76: .if t \ ! 77: drem(\(if,y) ! 78: to be invalid operations that produce a \*(nn. ! 79: On a VAX, drem(x,0) returns the reserved operand. No ! 80: .if n \ ! 81: infinity ! 82: .if t \ ! 83: \(if ! 84: exists on a VAX. ! 85: .PP ! 86: IEEE 754 defines ! 87: .if n \ ! 88: logb(\(+-infinity) = +infinity and logb(0) = \-infinity, ! 89: .if t \ ! 90: logb(\(+-\(if) = +\(if and logb(0) = \-\(if, and ! 91: requires the latter to signal Division\-by\-Zero. ! 92: But on a VAX, logb(0) = 1.0 \- 2.0**31 = \-2,147,483,647.0. ! 93: And if the correct value of scalb(x,n) would overflow on a VAX, ! 94: it returns the reserved operand and sets \fIerrno\fR to ERANGE. ! 95: .SH SEE ALSO ! 96: floor(3M), math(3M), infnan(3M) ! 97: .SH AUTHOR ! 98: Kwok\-Choi Ng ! 99: .SH BUGS ! 100: Should drem(x,0) and logb(0) on a VAX signal invalidity ! 101: by setting \fIerrno\fR = EDOM? Should logb(0) return \-1.7e38? ! 102: .PP ! 103: IEEE 754 currently specifies that ! 104: logb(denormalized no.) = logb(tiniest normalized no. > 0) ! 105: but the consensus has changed to the specification in the new ! 106: proposed IEEE standard p854, namely that logb(x) satisfy ! 107: .RS ! 108: 1 \(<= scalb(|x|,\-logb(x)) < Radix\0\0\0... = 2 for IEEE 754 ! 109: .RE ! 110: for every x except 0, ! 111: .if n \ ! 112: infinity ! 113: .if t \ ! 114: \(if ! 115: and \*(nn. ! 116: Almost every program that assumes 754's specification will work ! 117: correctly if logb follows 854's specification instead. ! 118: .PP ! 119: IEEE 754 requires copysign(x,\*(nn) = \(+-x but says nothing ! 120: else about the sign of a \*(nn. A \*(nn (\fIN\fRot \fIa\fR \fIN\fRumber) is ! 121: similar in spirit to the VAX's reserved operand, but very ! 122: different in important details. Since the sign bit of a ! 123: reserved operand makes it look negative, ! 124: .RS ! 125: copysign(x,reserved operand) = \-x; ! 126: .RE ! 127: should this return the reserved operand instead?
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.