1SCALB(3P) POSIX Programmer's Manual SCALB(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
12 scalb - load exponent of a radix-independent floating-point number
13
15 #include <math.h>
16
17 double scalb(double x, double n);
18
19
21 The scalb() function shall compute x*r**n, where r is the radix of the
22 machine's floating-point arithmetic. When r is 2, scalb() shall be
23 equivalent to ldexp(). The value of r is FLT_RADIX which is defined in
24 <float.h>.
25
26 An application wishing to check for error situations should set errno
27 to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these
28 functions. On return, if errno is non-zero or fetestexcept(FE_INVALID
29 | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error has
30 occurred.
31
33 Upon successful completion, the scalb() function shall return x*r**n.
34
35 If x or n is NaN, a NaN shall be returned.
36
37 If n is zero, x shall be returned.
38
39 If x is ±Inf and n is not -Inf, x shall be returned.
40
41 If x is ±0 and n is not +Inf, x shall be returned.
42
43 If x is ±0 and n is +Inf, a domain error shall occur, and either a NaN
44 (if supported), or an implementation-defined value shall be returned.
45
46 If x is ±Inf and n is -Inf, a domain error shall occur, and either a
47 NaN (if supported), or an implementation-defined value shall be
48 returned.
49
50 If the result would cause an overflow, a range error shall occur and
51 ±HUGE_VAL (according to the sign of x) shall be returned.
52
53 If the correct value would cause underflow, and is representable, a
54 range error may occur and the correct value shall be returned.
55
56 If the correct value would cause underflow, and is not representable, a
57 range error may occur, and 0.0 shall be returned.
58
60 The scalb() function shall fail if:
61
62 Domain Error
63 If x is zero and n is +Inf, or x is Inf and n is -Inf.
64
65 If the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
66 then errno shall be set to [EDOM]. If the integer expression
67 (math_errhandling & MATH_ERREXCEPT) is non-zero, then the invalid
68 floating-point exception shall be raised.
69
70 Range Error
71 The result would overflow.
72
73 If the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
74 then errno shall be set to [ERANGE]. If the integer expression
75 (math_errhandling & MATH_ERREXCEPT) is non-zero, then the overflow
76 floating-point exception shall be raised.
77
78
79 The scalb() function may fail if:
80
81 Range Error
82 The result underflows.
83
84 If the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
85 then errno shall be set to [ERANGE]. If the integer expression
86 (math_errhandling & MATH_ERREXCEPT) is non-zero, then the underflow
87 floating-point exception shall be raised.
88
89
90 The following sections are informative.
91
93 None.
94
96 Applications should use either scalbln(), scalblnf(), or scalblnl() in
97 preference to this function.
98
99 IEEE Std 1003.1-2001 only defines the behavior for the scalb() function
100 when the n argument is an integer, a NaN, or Inf. The behavior of other
101 values for the n argument is unspecified.
102
103 On error, the expressions (math_errhandling & MATH_ERRNO) and
104 (math_errhandling & MATH_ERREXCEPT) are independent of each other, but
105 at least one of them must be non-zero.
106
108 None.
109
111 None.
112
114 feclearexcept(), fetestexcept(), ilogb(), ldexp(), logb(), scalbln(),
115 the Base Definitions volume of IEEE Std 1003.1-2001, Section 4.18,
116 Treatment of Error Conditions for Mathematical Functions, <float.h>,
117 <math.h>
118
120 Portions of this text are reprinted and reproduced in electronic form
121 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
122 -- Portable Operating System Interface (POSIX), The Open Group Base
123 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
124 Electrical and Electronics Engineers, Inc and The Open Group. In the
125 event of any discrepancy between this version and the original IEEE and
126 The Open Group Standard, the original IEEE and The Open Group Standard
127 is the referee document. The original Standard can be obtained online
128 at http://www.opengroup.org/unix/online.html .
129
130
131
132IEEE/The Open Group 2003 SCALB(3P)