home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 25.ddi / root.2 / usr / ucbinclude / sunfp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-08  |  5.8 KB  |  266 lines

  1. /*    Copyright (c) 1990 UNIX System Laboratories, Inc.    */
  2. /*    Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T    */
  3. /*      All Rights Reserved      */
  4.  
  5. /*    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF         */
  6. /*    UNIX System Laboratories, Inc.                         */
  7. /*    The copyright notice above does not evidence any       */
  8. /*    actual or intended publication of such source code.    */
  9.  
  10.  
  11. #ident    "@(#)//usr/ucbinclude/sunfp.h.sl 1.1 4.0 12/08/90 40247 AT&T-USL"
  12.  
  13. /*******************************************************************
  14.  
  15.         PROPRIETARY NOTICE (Combined)
  16.  
  17. This source code is unpublished proprietary information
  18. constituting, or derived under license from AT&T's UNIX(r) System V.
  19. In addition, portions of such source code were derived from Berkeley
  20. 4.3 BSD under license from the Regents of the University of
  21. California.
  22.  
  23.  
  24.  
  25.         Copyright Notice 
  26.  
  27. Notice of copyright on this source code product does not indicate 
  28. publication.
  29.  
  30.     (c) 1986,1987,1988,1989  Sun Microsystems, Inc
  31.     (c) 1983,1984,1985,1986,1987,1988,1989  AT&T.
  32.               All rights reserved.
  33. ********************************************************************/ 
  34.  
  35. #include <fp.h>
  36.  
  37.     /*    Sun floating-point PRIVATE include file.  */
  38.  
  39.     /*    PRIVATE MACROS    */
  40.  
  41. #ifdef DEBUG
  42. #define PRIVATE
  43. #else
  44. #define PRIVATE static
  45. #endif
  46.  
  47. #define    DOUBLE_E(n) (n & 0xfffe )     /* More significant word of double. */
  48. #define DOUBLE_F(n) (1+DOUBLE_E(n))     /* Less significant word of double. */
  49.  
  50.     /*    PRIVATE CONSTANTS    */
  51.  
  52. #define INTEGER_BIAS       31
  53. #define    SINGLE_BIAS      127
  54. #define DOUBLE_BIAS     1023
  55. #define EXTENDED_BIAS    16383
  56.  
  57. #define DECIMAL_BINARY_INTEGER_SIZE 3088    /* Size of decimal to binary integer 
  58.                         conversion buffer. */
  59.  
  60. #define SINGLE_MAXE      97        /* Maximum decimal exponent we need to consider. */
  61. #define DOUBLE_MAXE     771        /* Maximum decimal exponent we need to consider. */
  62. #define EXTENDED_MAXE  12330        /* Maximum decimal exponent we need to consider. */
  63.  
  64.     /* PRIVATE TYPES     */
  65.  
  66. typedef struct        /* Type for passing partial results of decimal to binary conversion. */
  67.     {        /* Floating point of base B==2**16 with at least 80 significant bits. */
  68.             /* Interpreted as B**exponent * 0.s0s1s2s3s4s5 */
  69.      int    exponent ;        /* Signed exponent. */
  70.     unsigned significand[6] ;    /* Significand normalized so significand[0] >= 1 ; 
  71.                         significand[n] < 2**16. */
  72.                     /* Least significant bit can be sticky. */
  73.     }
  74.     big_float ;
  75.  
  76. typedef unsigned decimal_binary_integer_buffer[DECIMAL_BINARY_INTEGER_SIZE] ;
  77.  
  78. #ifdef i386
  79. typedef struct                    /* Most significant word formats. */
  80.     {
  81.     unsigned significand:    23 ;
  82.     unsigned exponent:    8 ;
  83.     unsigned sign:        1 ;
  84.     }
  85.     single_msw ;
  86.  
  87. typedef struct
  88.     {
  89.     unsigned significand:    20 ;
  90.     unsigned exponent:    11 ;
  91.     unsigned sign:        1 ;
  92.     }
  93.     double_msw ;
  94.  
  95. typedef struct
  96.     {
  97.     unsigned unused:    16 ;
  98.     unsigned exponent:    15 ;
  99.     unsigned sign:        1 ;
  100.     }
  101.     extended_msw ;
  102.  
  103. typedef struct                    /* Floating-point formats in detail. */
  104.     {
  105.     single_msw msw ;
  106.     }
  107.     single_formatted ;
  108.  
  109. typedef struct
  110.     {
  111.     unsigned significand2 ;
  112.     double_msw msw ;
  113.     }
  114.     double_formatted ;
  115.  
  116. typedef struct
  117.     {
  118.     unsigned significand2 ;
  119.     unsigned significand ;
  120.     extended_msw msw ;
  121.     }
  122.     extended_formatted ;
  123. #else
  124. typedef struct                    /* Most significant word formats. */
  125.     {
  126.     unsigned sign:        1 ;
  127.     unsigned exponent:    8 ;
  128.     unsigned significand:    23 ;
  129.     }
  130.     single_msw ;
  131.  
  132. typedef struct
  133.     {
  134.     unsigned sign:        1 ;
  135.     unsigned exponent:    11 ;
  136.     unsigned significand:    20 ;
  137.     }
  138.     double_msw ;
  139.  
  140. typedef struct
  141.     {
  142.     unsigned sign:        1 ;
  143.     unsigned exponent:    15 ;
  144.     unsigned unused:    16 ;
  145.     }
  146.     extended_msw ;
  147.  
  148. typedef struct                    /* Floating-point formats in detail. */
  149.     {
  150.     single_msw msw ;
  151.     }
  152.     single_formatted ;
  153.  
  154. typedef struct
  155.     {
  156.     double_msw msw ;
  157.     unsigned significand2 ;
  158.     }
  159.     double_formatted ;
  160.  
  161. typedef struct
  162.     {
  163.     extended_msw msw ;
  164.     unsigned significand ;
  165.     unsigned significand2 ;
  166.     }
  167.     extended_formatted ;
  168. #endif
  169.  
  170. typedef union                    /* Floating-point formats equivalenced. */
  171.     {
  172.     single_formatted     f ;
  173.     single             x ;
  174.     }
  175.     single_equivalence ;
  176.  
  177. typedef union
  178.     {
  179.     double_formatted     f ;
  180.     double             x ;
  181.     }
  182.     double_equivalence ;
  183.  
  184. typedef union
  185.     {
  186.     extended_formatted      f ;
  187.     extended         x ;
  188.     }
  189.     extended_equivalence ;
  190.  
  191. typedef struct                    /* Unpack floating-point internal format. */
  192.         {
  193.         int         sign ;
  194.         enum fp_class_type fpclass ;
  195.         int         exponent ;              /* Unbiased exponent. */
  196.         unsigned     significand[3] ;    /* Third word is round and sticky. */
  197.         }
  198.         unpacked ;
  199.  
  200.     /* PRIVATE GLOBAL VARIABLES */
  201.  
  202. fp_exception_field_type _fp_current_exceptions ; /* Current floating-point exceptions. */
  203.  
  204. enum fp_direction_type
  205.         _fp_current_direction ;    /* Current rounding direction. */
  206.  
  207. enum fp_precision_type
  208.         _fp_current_precision ; /* Current rounding precision. */
  209.  
  210.     /* PRIVATE FUNCTIONS */
  211.  
  212. extern void _fp_normalize (/* pu */) ;
  213. /*        unpacked        *pu ;           /* unpacked operand and result */
  214.  
  215. extern void _fp_rightshift (/* pu, n */) ;
  216. /*    unpacked *pu ; unsigned n ;    */
  217. /*      Right shift significand sticky by n bits.  */
  218.  
  219. extern void _fp_set_exception(/* ex */) ;
  220. /*    enum fp_exception_type ex ;    /* exception to be set in curexcep */ 
  221.  
  222. extern void _unpack_integer () ; /* pu, px )     *pu gets *px unpacked
  223. unpacked    *pu ;
  224. integer        *px ;
  225. */
  226.  
  227. extern void _unpack_single () ; /* pu, px )
  228. unpacked    *pu ;
  229. integer        *px ;
  230. */
  231.  
  232. extern void _unpack_double () ; /* pu, px )
  233. unpacked    *pu ;
  234. integer        *px ;
  235. */
  236.  
  237. extern void _unpack_extended () ; /* pu, px )
  238. unpacked    *pu ;
  239. integer        *px ;
  240. */
  241.  
  242. extern void _pack_integer () ; /* pu, px )        *px gets packed *pu
  243. unpacked    *pu ;
  244. integer        *px ;
  245. */
  246.  
  247. extern void _pack_single () ; /* pu, px )
  248. unpacked    *pu ;
  249. integer        *px ;
  250. */
  251.  
  252. extern void _pack_double () ; /* pu, px )
  253. unpacked    *pu ;
  254. integer        *px ;
  255. */
  256.  
  257. extern void _pack_extended () ; /* pu, px )
  258. unpacked    *pu ;
  259. integer        *px ;
  260. */
  261.  
  262. extern enum fp_class_type class_single () ;
  263. extern enum fp_class_type class_double () ;
  264. extern enum fp_class_type class_extended () ;
  265.  
  266.