Leaked source code of windows server 2003
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.

40 lines
929 B

  1. /* _FDnorm function -- IEEE 754 version */
  2. #include "wctype.h"
  3. #include "xmath.h"
  4. _STD_BEGIN
  5. _CRTIMP2 short _FDnorm(unsigned short *ps)
  6. { /* normalize float fraction */
  7. short xchar;
  8. unsigned short sign = ps[_F0] & _FSIGN;
  9. xchar = 1;
  10. if ((ps[_F0] &= _FFRAC) != 0 || ps[_F1])
  11. { /* nonzero, scale */
  12. if (ps[_F0] == 0)
  13. ps[_F0] = ps[_F1], ps[_F1] = 0, xchar -= 16;
  14. for (; ps[_F0] < 1<<_FOFF; --xchar)
  15. { /* shift left by 1 */
  16. ps[_F0] = ps[_F0] << 1 | ps[_F1] >> 15;
  17. ps[_F1] <<= 1;
  18. }
  19. for (; 1<<(_FOFF+1) <= ps[_F0]; ++xchar)
  20. { /* shift right by 1 */
  21. ps[_F1] = ps[_F1] >> 1 | ps[_F0] << 15;
  22. ps[_F0] >>= 1;
  23. }
  24. ps[_F0] &= _FFRAC;
  25. }
  26. ps[_F0] |= sign;
  27. return (xchar);
  28. }
  29. _STD_END
  30. /*
  31. * Copyright (c) 1994 by P.J. Plauger. ALL RIGHTS RESERVED.
  32. * Consult your license regarding permissions and restrictions.
  33. */
  34. /*
  35. 941029 pjp: added _STD machinery
  36. */