summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordas <das@FreeBSD.org>2004-06-20 09:25:27 +0000
committerdas <das@FreeBSD.org>2004-06-20 09:25:27 +0000
commitdd81b94d1c7301a13decfd4320464121126e3952 (patch)
tree8fbea8c3c6c5a1745baeae5bd6ea5da41b0e08b5
parentd711478366fb98d9f5712539d1662be350da961e (diff)
downloadFreeBSD-src-dd81b94d1c7301a13decfd4320464121126e3952.zip
FreeBSD-src-dd81b94d1c7301a13decfd4320464121126e3952.tar.gz
Add trivial implementations of scalbln() and scalblnf().
These routines are specified in C99 for the sake of architectures where an int isn't big enough to represent the full range of floating-point exponents. However, even the 128-bit long double format has an exponent smaller than 15 bits, so for all practical purposes, scalbln() and scalblnf() are aliases for scalbn() and scalbnf(), respectively.
-rw-r--r--lib/msun/man/ieee.319
-rw-r--r--lib/msun/src/s_scalbln.c44
2 files changed, 59 insertions, 4 deletions
diff --git a/lib/msun/man/ieee.3 b/lib/msun/man/ieee.3
index fa81b06..9cd9e94 100644
--- a/lib/msun/man/ieee.3
+++ b/lib/msun/man/ieee.3
@@ -32,7 +32,7 @@
.\" from: @(#)ieee.3 6.4 (Berkeley) 5/6/91
.\" $FreeBSD$
.\"
-.Dd February 25, 1994
+.Dd June 20, 2004
.Dt IEEE 3
.Os
.Sh NAME
@@ -47,6 +47,8 @@
.Nm nextafterf ,
.Nm remainder ,
.Nm remainderf ,
+.Nm scalbln ,
+.Nm scalblnf ,
.Nm scalbn ,
.Nm scalbnf
.Nd functions for IEEE arithmetic
@@ -77,6 +79,10 @@
.Ft float
.Fn remainderf "float x" "float y"
.Ft double
+.Fn scalbln "double x" "long n"
+.Ft float
+.Fn scalblnf "float x" "long n"
+.Ft double
.Fn scalbn "double x" "int n"
.Ft float
.Fn scalbnf "float x" "int n"
@@ -173,7 +179,9 @@ and
.Fn remainder \*(If 0
are invalid operations that produce a \*(Na.
.Pp
-.Fn scalbn
+.Fn scalbln ,
+.Fn scalblnf ,
+.Fn scalbn ,
and
.Fn scalbnf
return
@@ -187,8 +195,11 @@ The
functions appeared in
.Bx 4.3 .
The
-.Fn copysignl
-function first appeared in
+.Fn copysignl ,
+.Fn scalbln ,
+and
+.Fn scalblnf
+functions first appeared in
.Fx 5.3 .
.Sh STANDARDS
.St -ieee754
diff --git a/lib/msun/src/s_scalbln.c b/lib/msun/src/s_scalbln.c
new file mode 100644
index 0000000..73b1d27
--- /dev/null
+++ b/lib/msun/src/s_scalbln.c
@@ -0,0 +1,44 @@
+/*-
+ * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <math.h>
+
+double
+scalbln (double x, long n)
+{
+
+ return (scalbn(x, (int)n));
+}
+
+float
+scalblnf (float x, long n)
+{
+
+ return (scalbnf(x, (int)n));
+}
OpenPOWER on IntegriCloud