Source code of Windows XP (NT5)
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.

35 lines
856 B

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