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.
This commit is contained in:
das 2004-06-20 09:25:27 +00:00
parent d711478366
commit dd81b94d1c
2 changed files with 59 additions and 4 deletions

View File

@ -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

44
lib/msun/src/s_scalbln.c Normal file
View File

@ -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));
}