xref: /illumos-gate/usr/src/man/man3m/scalb.3m (revision 63f91fbc3c024870d86dc3332a4a0080fb29bc40)
1.\"
2.\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3.\" permission to reproduce portions of its copyrighted documentation.
4.\" Original documentation from The Open Group can be obtained online at
5.\" http://www.opengroup.org/bookstore/.
6.\"
7.\" The Institute of Electrical and Electronics Engineers and The Open
8.\" Group, have given us permission to reprint portions of their
9.\" documentation.
10.\"
11.\" In the following statement, the phrase ``this text'' refers to portions
12.\" of the system documentation.
13.\"
14.\" Portions of this text are reprinted and reproduced in electronic form
15.\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16.\" Standard for Information Technology -- Portable Operating System
17.\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18.\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19.\" Engineers, Inc and The Open Group.  In the event of any discrepancy
20.\" between these versions and the original IEEE and The Open Group
21.\" Standard, the original IEEE and The Open Group Standard is the referee
22.\" document.  The original Standard can be obtained online at
23.\" http://www.opengroup.org/unix/online.html.
24.\"
25.\" This notice shall appear on any product containing this material.
26.\"
27.\" The contents of this file are subject to the terms of the
28.\" Common Development and Distribution License (the "License").
29.\" You may not use this file except in compliance with the License.
30.\"
31.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32.\" or http://www.opensolaris.org/os/licensing.
33.\" See the License for the specific language governing permissions
34.\" and limitations under the License.
35.\"
36.\" When distributing Covered Code, include this CDDL HEADER in each
37.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38.\" If applicable, add the following below this CDDL HEADER, with the
39.\" fields enclosed by brackets "[]" replaced with your own identifying
40.\" information: Portions Copyright [yyyy] [name of copyright owner]
41.\"
42.\"
43.\" Copyright (c) 1992, X/Open Company Limited.  All Rights Reserved.
44.\" Copyright (c) 2001, The IEEE and The Open Group.  All Rights Reserved.
45.\" Portions Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved.
46.\" Portions Copyright 2019 Garrett D'Amore <garrett@damore.org>
47.Dd Jul 05, 2019
48.Dt SCALB 3M
49.Os
50.Sh NAME
51.Nm scalb ,
52.Nm scalbf ,
53.Nm scalbl
54.Nd load exponent of a radix-independent floating-point number
55.Sh SYNOPSIS
56.Ic c99 Oo Ar flag Ns ... Oc Ar file Ns ... Fl lm Op Ar library Ns ...
57.Pp
58.In math.h
59.
60.Ft double
61.Fo scalb
62.Fa "double x"
63.Fa "double n"
64.Fc
65.
66.Ft float
67.Fo scalbf
68.Fa "float x"
69.Fa "float n"
70.Fc
71.
72.Ft "long double"
73.Fo scalbl
74.Fa "long double x"
75.Fa "long double n"
76.Fc
77.
78.Sh DESCRIPTION
79These functions compute
80.Fa x No * Va r Ns No ^ Ns Fa n ,
81where
82.Va r
83is the radix of the machine's floating point arithmetic.
84When
85.Va r
86is 2,
87.Fn scalb
88is equivalent to
89.Xr ldexp 3M .
90The value of
91.Va r
92is
93.Dv FLT_RADIX
94which is
95defined in
96.In float.h .
97.Sh RETURN VALUES
98Upon successful completion, the
99.Fn scalb
100function returns
101.Fa x No * Va r Ns No ^ Ns Fa n .
102.Pp
103If
104.Fa x
105or
106.Fa n
107is
108.Sy NaN ,
109a
110.Sy NaN
111is returned.
112.Lp
113If
114.Fa n
115is 0,
116.Fa x
117is returned.
118.Lp
119If
120.Fa x
121is
122.Sy \(+-Inf
123and
124.Fa n
125is not
126.Sy \(miInf ,
127.Fa x
128is returned.
129.Lp
130If
131.Fa x
132is \(+-0 and
133.Fa n
134is not
135.Sy +Inf ,
136.Fa x
137is returned.
138.Lp
139If
140.Fa x
141is \(+-0 and
142.Fa n
143is
144.Sy +Inf ,
145a domain error occurs and a
146.Sy NaN
147is returned.
148.Lp
149If
150.Fa x
151is
152.Sy \(+-Inf
153and
154Fa n
155is
156.Sy \(miInf ,
157a domain error occurs and a
158.Sy NaN
159is returned.
160.Lp
161If the result would cause an overflow, a range error occurs and
162.Dv \(+-HUGE_VAL
163(according to the sign of
164.Fa x )
165is returned.
166.Lp
167For exceptional cases,
168.Xr matherr 3M
169tabulates the values to be returned by
170.Fn scalb
171as specified by SVID3 and XPG3.
172See
173.Xr standards 7 .
174.
175.Sh ERRORS
176.
177These functions will fail if:
178.
179.Bl -tag -width Sy
180.It Sy Domain Error
181If
182.Fa x
183is 0 and
184.Fa n
185is
186.Sy +Inf ,
187or
188.Fa x
189is
190.Sy Inf
191and
192.Fa n
193is
194.Sy \(miInf .
195.Lp
196If the integer expression
197.Po Va math_errhandling No & Dv MATH_ERREXCEPT Pc
198.\" (\fBmath_errhandling\fR & \fBMATH_ERREXCEPT\fR)
199is non-zero, then the invalid floating-point exception is raised.
200.
201.It Sy Range Error
202The result would overflow.
203.Lp
204If the integer expression
205.Po Va math_errhandling No & Dv MATH_ERREXCEPT Pc
206is non-zero, then the overflow floating-point exception is raised.
207.El
208.
209.Sh USAGE
210An application wanting to check for exceptions should call
211.Fn feclearexcept FE_ALL_EXCEPT
212before calling these functions.
213On return, if
214.Fn fetestexcept "FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW"
215is non-zero, an exception has been raised.
216An application should either examine the return value or check the
217floating point exception flags to detect exceptions.
218.
219.Lp
220.
221These functions are
222.Sy Obsolete .
223The
224.Xr scalbln 3M ,
225.Xr scalblnf 3M ,
226or
227.Xr scalblnl 3M
228functions should be used instead.
229.
230.Sh MT-LEVEL
231.
232.Sy MT-Safe .
233.
234.Sh INTERFACE STABILITY
235.
236The
237.Fn scalb
238function is
239.Sy Obsolete Standard .
240The
241.Fn scalbf
242and
243.Fn scalbl
244functions are
245.Sy Obsolete Committed .
246.
247.Sh SEE ALSO
248.
249.Xr math.h 3HEAD ,
250.Xr feclearexcept 3M ,
251.Xr fetestexcept 3M ,
252.Xr ilogb 3M ,
253.Xr ldexp 3M ,
254.Xr logb 3M ,
255.Xr matherr 3M ,
256.Xr scalbln 3M ,
257.Xr attributes 7 ,
258.Xr standards 7
259