os/ossrv/genericopenlibs/cstdlib/LMATH/S_LDEXP.C
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/cstdlib/LMATH/S_LDEXP.C	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,86 @@
     1.4 +/* S_LDEXP.C
     1.5 + * 
     1.6 + * Portions Copyright (c) 1993-2005 Nokia Corporation and/or its subsidiary(-ies).
     1.7 + * All rights reserved.
     1.8 + */
     1.9 +
    1.10 +
    1.11 +/* @(#)s_ldexp.c 5.1 93/09/24 */
    1.12 +/*
    1.13 + * ====================================================
    1.14 + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
    1.15 + *
    1.16 + * Developed at SunPro, a Sun Microsystems, Inc. business.
    1.17 + * Permission to use, copy, modify, and distribute this
    1.18 + * software is freely granted, provided that this notice 
    1.19 + * is preserved.
    1.20 + * ====================================================
    1.21 + */
    1.22 +
    1.23 +/*
    1.24 +FUNCTION
    1.25 +       <<ldexp>>, <<ldexpf>>---load exponent
    1.26 +
    1.27 +INDEX
    1.28 +	ldexp
    1.29 +INDEX
    1.30 +	ldexpf
    1.31 +
    1.32 +ANSI_SYNOPSIS
    1.33 +       #include <math.h>
    1.34 +       double ldexp(double <[val]>, int <[exp]>);
    1.35 +       float ldexpf(float <[val]>, int <[exp]>);
    1.36 +
    1.37 +TRAD_SYNOPSIS
    1.38 +       #include <math.h>
    1.39 +
    1.40 +       double ldexp(<[val]>, <[exp]>)
    1.41 +              double <[val]>;
    1.42 +              int <[exp]>;
    1.43 +
    1.44 +       float ldexpf(<[val]>, <[exp]>)
    1.45 +              float <[val]>;
    1.46 +              int <[exp]>;
    1.47 +
    1.48 +
    1.49 +DESCRIPTION
    1.50 +<<ldexp>> calculates the value 
    1.51 +@ifinfo
    1.52 +<[val]> times 2 to the power <[exp]>.
    1.53 +@end ifinfo
    1.54 +@tex
    1.55 +$val\times 2^{exp}$.
    1.56 +@end tex
    1.57 +<<ldexpf>> is identical, save that it takes and returns <<float>>
    1.58 +rather than <<double>> values.
    1.59 +
    1.60 +RETURNS
    1.61 +<<ldexp>> returns the calculated value.
    1.62 +
    1.63 +Underflow and overflow both set <<errno>> to <<ERANGE>>.
    1.64 +On underflow, <<ldexp>> and <<ldexpf>> return 0.0.
    1.65 +On overflow, <<ldexp>> returns plus or minus <<HUGE_VAL>>.
    1.66 +
    1.67 +PORTABILITY
    1.68 +<<ldexp>> is ANSI, <<ldexpf>> is an extension.
    1.69 +              
    1.70 +*/   
    1.71 +
    1.72 +#include "FDLIBM.H"
    1.73 +#include <errno.h>
    1.74 +
    1.75 +/**
    1.76 +Get floating-point value from mantissa and exponent.
    1.77 +Calculates the floating point value corresponding to 
    1.78 +the given mantissa and exponent
    1.79 +@return   Floating-point value equal to value * 2exp.
    1.80 +@param x Floating point value representing mantissa 
    1.81 +@param exp Integer exponent
    1.82 +*/	
    1.83 +EXPORT_C double ldexp(double value, int exp) __SOFTFP
    1.84 +{
    1.85 +	if(!finite(value)||value==0.0) return value;
    1.86 +	value = scalbn(value,exp);
    1.87 +	if(!finite(value)||value==0.0) errno = ERANGE;
    1.88 +	return value;
    1.89 +}