s_ldexp.c 864 B

1234567891011121314151617181920212223242526272829303132
  1. /* @(#)s_ldexp.c 5.1 93/09/24 */
  2. /*
  3. * ====================================================
  4. * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
  5. *
  6. * Developed at SunPro, a Sun Microsystems, Inc. business.
  7. * Permission to use, copy, modify, and distribute this
  8. * software is freely granted, provided that this notice
  9. * is preserved.
  10. * ====================================================
  11. */
  12. #if defined(LIBM_SCCS) && !defined(lint)
  13. static char rcsid[] = "$NetBSD: s_ldexp.c,v 1.6 1995/05/10 20:47:40 jtc Exp $";
  14. #endif
  15. #include "math.h"
  16. #include "math_private.h"
  17. #include <errno.h>
  18. #ifdef __STDC__
  19. double ldexp(double value, int exp)
  20. #else
  21. double ldexp(value, exp)
  22. double value; int exp;
  23. #endif
  24. {
  25. if(!finite(value)||value==0.0) return value;
  26. value = scalbn(value,exp);
  27. if(!finite(value)||value==0.0) errno = ERANGE;
  28. return value;
  29. }