1scalb(3M) Mathematical Library Functions scalb(3M)
2
3
4
6 scalb, scalbf, scalbl - load exponent of a radix-independent floating-
7 point number
8
10 c99 [ flag... ] file... -lm [ library... ]
11 #include <math.h>
12
13 double scalb(double x, double n);
14
15
16 float scalbf(float x, float n);
17
18
19 long double scalbl(long double x, long double n);
20
21
23 These functions compute x * r^n, where r is the radix of the machine's
24 floating point arithmetic. When r is 2, scalb() is equivalent to
25 ldexp(3M). The value of r is FLT_RADIX which is defined in <float.h>.
26
28 Upon successful completion, the scalb() function returns x * r^n.
29
30
31 If x or n is NaN, a NaN is returned.
32
33
34 If n is 0, x is returned.
35
36
37 If x is ±Inf and n is not −Inf, x is returned.
38
39
40 If x is ±0 and n is not +Inf, x is returned.
41
42
43 If x is ±0 and n is +Inf, a domain error occurs and a NaN is returned.
44
45
46 If x is ±Inf and n is −Inf, a domain error occurs and a NaN is
47 returned.
48
49
50 If the result would cause an overflow, a range error occurs and
51 ±HUGE_VAL (according to the sign of x) is returned.
52
53
54 For exceptional cases, matherr(3M) tabulates the values to be returned
55 by scalb() as specified by SVID3 and XPG3. See standards(5).
56
58 These functions will fail if:
59
60 Domain Error If x is 0 and n is +Inf, or x is Inf and n is −Inf.
61
62 If the integer expression (math_errhandling &
63 MATH_ERREXCEPT) is non-zero, then the invalid floating-
64 point exception is raised.
65
66
67 Range Error The result would overflow.
68
69 If the integer expression (math_errhandling &
70 MATH_ERREXCEPT) is non-zero, then the overflow float‐
71 ing-point exception is raised.
72
73
75 An application wanting to check for exceptions should call feclearex‐
76 cept(FE_ALL_EXCEPT) before calling these functions. On return, if
77 fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is
78 non-zero, an exception has been raised. An application should either
79 examine the return value or check the floating point exception flags to
80 detect exceptions.
81
83 See attributes(5) for descriptions of the following attributes:
84
85
86
87
88 ┌─────────────────────────────┬─────────────────────────────┐
89 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
90 ├─────────────────────────────┼─────────────────────────────┤
91 │Interface Stability │See below. │
92 ├─────────────────────────────┼─────────────────────────────┤
93 │MT-Level │MT-Safe │
94 └─────────────────────────────┴─────────────────────────────┘
95
96
97 The scalb() function is Standard. The scalbf() and scalbl() functions
98 are Stable.
99
101 feclearexcept(3M), fetestexcept(3M), ilogb(3M), ldexp(3M), logb(3M),
102 math.h(3HEAD), matherr(3M), scalbln(3M), attributes(5), standards(5)
103
104
105
106SunOS 5.11 12 Jul 2006 scalb(3M)