home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue2 / SDL.ARC / !unixlib / source / clib / machine / h / ieee754 < prev   
Encoding:
Text File  |  2004-09-05  |  2.2 KB  |  107 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /usr/local/cvsroot/gccsdk/unixlib/source/clib/machine/ieee754.h,v $
  4.  * $Date: 2002/09/24 21:02:37 $
  5.  * $Revision: 1.4 $
  6.  * $State: Exp $
  7.  * $Author: admin $
  8.  *
  9.  ***************************************************************************/
  10.  
  11. #ifndef __MACHINE_IEEE754_H
  12. #define __MACHINE_IEEE754_H 1
  13.  
  14. #ifndef __UNIXLIB_FEATURES_H
  15. #include <unixlib/features.h>
  16. #endif
  17.  
  18. __BEGIN_DECLS
  19.  
  20. union ieee754_float
  21.   {
  22.     float f;
  23.  
  24.     /* This is the IEEE 754 single-precision format.  */
  25.     struct
  26.       {
  27.     unsigned int mantissa:23;
  28.     unsigned int exponent:8;
  29.     unsigned int negative:1;
  30.       } ieee;
  31.  
  32.     /* This format makes it easier to see if a NaN is a signalling NaN.  */
  33.     struct
  34.       {
  35.     unsigned int mantissa:22;
  36.     unsigned int quiet_nan:1;
  37.     unsigned int exponent:8;
  38.     unsigned int negative:1;
  39.       } ieee_nan;
  40.   };
  41.  
  42. #define IEEE754_FLOAT_BIAS    0x7f /* Added to exponent.  */
  43.  
  44.  
  45. union ieee754_double
  46.   {
  47.     double d;
  48.  
  49.     /* This is the IEEE 754 double-precision format.  */
  50.     struct
  51.       {
  52.     unsigned int mantissa0:20;
  53.     unsigned int exponent:11;
  54.     unsigned int negative:1;
  55.     unsigned int mantissa1:32;
  56.       } ieee;
  57.  
  58.     /* This format makes it easier to see if a NaN is a signalling NaN.  */
  59.     struct
  60.       {
  61.     unsigned int mantissa0:19;
  62.     unsigned int quiet_nan:1;
  63.     unsigned int exponent:11;
  64.     unsigned int negative:1;
  65.     unsigned int mantissa1:32;
  66.       } ieee_nan;
  67.   };
  68.  
  69. #define IEEE754_DOUBLE_BIAS    0x3ff /* Added to exponent.  */
  70.  
  71.  
  72. union ieee854_long_double
  73.   {
  74.     long double d;
  75.  
  76.     /* This is the IEEE 854 double-extended-precision format.  */
  77.     struct
  78.       {
  79.     unsigned int exponent:15;
  80.     unsigned int empty:16;
  81.     unsigned int negative:1;
  82.     unsigned int mantissa0:32;
  83.     unsigned int mantissa1:32;
  84.       } ieee;
  85.  
  86.     /* This is for NaNs in the IEEE 854 double-extended-precision format.  */
  87.     struct
  88.       {
  89.     unsigned int exponent:15;
  90.     unsigned int empty:16;
  91.     unsigned int negative:1;
  92.     unsigned int mantissa0:30;
  93.     unsigned int quiet_nan:1;
  94.     unsigned int one:1;
  95.     unsigned int mantissa1:32;
  96.       } ieee_nan;
  97.   };
  98.  
  99. #define IEEE854_LONG_DOUBLE_BIAS 0x3fff
  100.  
  101.  
  102. extern double __ieee754_exp (double __x);
  103.  
  104. __END_DECLS
  105.  
  106. #endif
  107.