glibc/sysdeps/ieee754/ldbl-96/s_scalblnl.c
Siddhesh Poyarekar 30891f35fa Remove "Contributed by" lines
We stopped adding "Contributed by" or similar lines in sources in 2012
in favour of git logs and keeping the Contributors section of the
glibc manual up to date.  Removing these lines makes the license
header a bit more consistent across files and also removes the
possibility of error in attribution when license blocks or files are
copied across since the contributed-by lines don't actually reflect
reality in those cases.

Move all "Contributed by" and similar lines (Written by, Test by,
etc.) into a new file CONTRIBUTED-BY to retain record of these
contributions.  These contributors are also mentioned in
manual/contrib.texi, so we just maintain this additional record as a
courtesy to the earlier developers.

The following scripts were used to filter a list of files to edit in
place and to clean up the CONTRIBUTED-BY file respectively.  These
were not added to the glibc sources because they're not expected to be
of any use in future given that this is a one time task:

https://gist.github.com/siddhesh/b5ecac94eabfd72ed2916d6d8157e7dc
https://gist.github.com/siddhesh/15ea1f5e435ace9774f485030695ee02

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-09-03 22:06:44 +05:30

59 lines
1.7 KiB
C

/* s_scalbnl.c -- long double version of s_scalbn.c.
*/
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
/*
* scalbnl (long double x, int n)
* scalbnl(x,n) returns x* 2**n computed by exponent
* manipulation rather than by actually performing an
* exponentiation or a multiplication.
*/
#include <math.h>
#include <math_private.h>
static const long double
two63 = 0x1p63L,
twom64 = 0x1p-64L,
huge = 1.0e+4900L,
tiny = 1.0e-4900L;
long double
__scalblnl (long double x, long int n)
{
int32_t k,es,hx,lx;
GET_LDOUBLE_WORDS(es,hx,lx,x);
k = es&0x7fff; /* extract exponent */
if (__builtin_expect(k==0, 0)) { /* 0 or subnormal x */
if ((lx|(hx&0x7fffffff))==0) return x; /* +-0 */
x *= two63;
GET_LDOUBLE_EXP(es,x);
k = (es&0x7fff) - 63;
}
if (__builtin_expect(k==0x7fff, 0)) return x+x; /* NaN or Inf */
if (__builtin_expect(n< -50000, 0))
return tiny*copysignl(tiny,x);
if (__builtin_expect(n> 50000 || k+n > 0x7ffe, 0))
return huge*copysignl(huge,x); /* overflow */
/* Now k and n are bounded we know that k = k+n does not
overflow. */
k = k+n;
if (__builtin_expect(k > 0, 1)) /* normal result */
{SET_LDOUBLE_EXP(x,(es&0x8000)|k); return x;}
if (k <= -64)
return tiny*copysignl(tiny,x); /*underflow*/
k += 64; /* subnormal result */
SET_LDOUBLE_EXP(x,(es&0x8000)|k);
return x*twom64;
}