sl@0: /* S_LDEXP.C sl@0: * sl@0: * Portions Copyright (c) 1993-2005 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: */ sl@0: sl@0: sl@0: /* @(#)s_ldexp.c 5.1 93/09/24 */ sl@0: /* sl@0: * ==================================================== sl@0: * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. sl@0: * sl@0: * Developed at SunPro, a Sun Microsystems, Inc. business. sl@0: * Permission to use, copy, modify, and distribute this sl@0: * software is freely granted, provided that this notice sl@0: * is preserved. sl@0: * ==================================================== sl@0: */ sl@0: sl@0: /* sl@0: FUNCTION sl@0: <>, <>---load exponent sl@0: sl@0: INDEX sl@0: ldexp sl@0: INDEX sl@0: ldexpf sl@0: sl@0: ANSI_SYNOPSIS sl@0: #include sl@0: double ldexp(double <[val]>, int <[exp]>); sl@0: float ldexpf(float <[val]>, int <[exp]>); sl@0: sl@0: TRAD_SYNOPSIS sl@0: #include sl@0: sl@0: double ldexp(<[val]>, <[exp]>) sl@0: double <[val]>; sl@0: int <[exp]>; sl@0: sl@0: float ldexpf(<[val]>, <[exp]>) sl@0: float <[val]>; sl@0: int <[exp]>; sl@0: sl@0: sl@0: DESCRIPTION sl@0: <> calculates the value sl@0: @ifinfo sl@0: <[val]> times 2 to the power <[exp]>. sl@0: @end ifinfo sl@0: @tex sl@0: $val\times 2^{exp}$. sl@0: @end tex sl@0: <> is identical, save that it takes and returns <> sl@0: rather than <> values. sl@0: sl@0: RETURNS sl@0: <> returns the calculated value. sl@0: sl@0: Underflow and overflow both set <> to <>. sl@0: On underflow, <> and <> return 0.0. sl@0: On overflow, <> returns plus or minus <>. sl@0: sl@0: PORTABILITY sl@0: <> is ANSI, <> is an extension. sl@0: sl@0: */ sl@0: sl@0: #include "FDLIBM.H" sl@0: #include sl@0: sl@0: /** sl@0: Get floating-point value from mantissa and exponent. sl@0: Calculates the floating point value corresponding to sl@0: the given mantissa and exponent sl@0: @return Floating-point value equal to value * 2exp. sl@0: @param x Floating point value representing mantissa sl@0: @param exp Integer exponent sl@0: */ sl@0: EXPORT_C double ldexp(double value, int exp) __SOFTFP sl@0: { sl@0: if(!finite(value)||value==0.0) return value; sl@0: value = scalbn(value,exp); sl@0: if(!finite(value)||value==0.0) errno = ERANGE; sl@0: return value; sl@0: }