Windows NT 4.0 source code leak
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.2 KiB

4 years ago
  1. /***
  2. *frexp.c - get mantissa and exponent of a floating point number
  3. *
  4. * Copyright (c) 1991-1991, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. *
  8. *Revision History:
  9. * 8-24-91 GDP written
  10. * 1-13-92 GDP support IEEE exceptions
  11. *
  12. *******************************************************************************/
  13. #include <math.h>
  14. #include <trans.h>
  15. /***
  16. *double frexp(double x, double *expptr)
  17. *
  18. *Purpose:
  19. * The nomalized fraction f is returned: .5<=f<1
  20. * The exponent is stored in the object pointed by expptr
  21. *
  22. *Entry:
  23. *
  24. *Exit:
  25. *
  26. *Exceptions:
  27. * NAN: domain error
  28. *
  29. *******************************************************************************/
  30. double frexp(double x, int *expptr)
  31. {
  32. unsigned int savedcw;
  33. double man;
  34. /* save user fp control word */
  35. savedcw = _maskfp();
  36. /* check for infinity or NAN */
  37. if (IS_D_SPECIAL(x)){
  38. *expptr = INT_NAN;
  39. switch (_sptype(x)) {
  40. case T_PINF:
  41. return _except1(FP_I, OP_FREXP, x, D_INF, savedcw);
  42. case T_NINF:
  43. return _except1(FP_I, OP_FREXP, x, -D_INF, savedcw);
  44. case T_QNAN:
  45. return _handle_qnan1(OP_FREXP, x, savedcw);
  46. default: //T_SNAN
  47. return _except1(FP_I, OP_FREXP, x, _s2qnan(x), savedcw);
  48. }
  49. }
  50. man = _decomp(x, expptr);
  51. RETURN(savedcw,man);
  52. }