home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / LIBC / LIBC-4.6 / LIBC-4 / libc-linux / sysdeps / linux / i386 / math / fpclassifyf.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-19  |  1.8 KB  |  86 lines

  1. /* Copyright (C) 1993  Olaf Flebbe
  2. This file is part of the Linux C Library.
  3.  
  4. The Linux C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8.  
  9. The Linux C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. Library General Public License for more details. */
  13.  
  14.  
  15. /* YES: DO NOT INCLUDE ANY HEADER FILES.
  16.    TYPE CONVERTING, YUCK! */
  17.  
  18. #define FP_NAN       1
  19. #define FP_INFINITE  2
  20. #define FP_NORMAL    3
  21. #define FP_SUBNORMAL 4
  22. #define FP_ZERO      5
  23.  
  24. int fpclassifyf( unsigned int x) {
  25.   unsigned int y;
  26.  
  27.   x <<= 1;
  28.   y = x & 0xff000000;
  29.   x = x & 0x00ffffff;
  30.  
  31.   if (y == 0xff000000) {
  32.     /* i.e. NaN or Inf */
  33.     if (x) 
  34.       return FP_NAN;
  35.     else
  36.       return FP_INFINITE;
  37.   } else if (y) 
  38.     return FP_NORMAL;
  39.   else if (x)
  40.     return FP_SUBNORMAL;
  41.   else
  42.     return FP_ZERO;
  43. }
  44.  
  45. int fpclassifyd( unsigned int x2, unsigned int x1) {
  46.   unsigned int y;
  47.  
  48.   y  = x1 & 0x7ff00000;
  49.   x1 = (x1 & 0x000fffff)| x2;
  50.  
  51.   if (y == 0x7ff00000) {
  52.     /* i.e. NaN or Inf */
  53.     if (x1) 
  54.       return FP_NAN;
  55.     else
  56.       return FP_INFINITE;
  57.   } else if (y) 
  58.     return FP_NORMAL;
  59.   else if (x1)
  60.     return FP_SUBNORMAL;
  61.   else
  62.     return FP_ZERO;
  63. }
  64.  
  65. int fpclassifyl( unsigned int x3, unsigned int x2,
  66.           unsigned int x1) {
  67.   unsigned int y;
  68.  
  69.   y  = x1 & 0x00007fff;
  70.   x1 = (x2 & 0x7fffffff) | x3;
  71.  
  72.   if (y == 0x00007fff) {
  73.     /* i.e. NaN or Inf */
  74.     if (x1) 
  75.       return FP_NAN;
  76.     else
  77.       return FP_INFINITE;
  78.   } else if (y) 
  79.     return FP_NORMAL;
  80.   else if (x1)
  81.     return FP_SUBNORMAL; /* WHAT ABOUT PSEUDODENORMALS ???????? */
  82.   else
  83.     return FP_ZERO;
  84. }
  85.  
  86.