Annotation of GNUtools/cctools/as/flonum.h, revision 1.1

1.1     ! root        1: /* flonum.h - Floating point package
        !             2:    Copyright (C) 1987 Free Software Foundation, Inc.
        !             3: 
        !             4: This file is part of GAS, the GNU Assembler.
        !             5: 
        !             6: GAS is free software; you can redistribute it and/or modify
        !             7: it under the terms of the GNU General Public License as published by
        !             8: the Free Software Foundation; either version 1, or (at your option)
        !             9: any later version.
        !            10: 
        !            11: GAS is distributed in the hope that it will be useful,
        !            12: but WITHOUT ANY WARRANTY; without even the implied warranty of
        !            13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        !            14: GNU General Public License for more details.
        !            15: 
        !            16: You should have received a copy of the GNU General Public License
        !            17: along with GAS; see the file COPYING.  If not, write to
        !            18: the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
        !            19: 
        !            20: /***********************************************************************\
        !            21: *                                                                      *
        !            22: *      Arbitrary-precision floating point arithmetic.                  *
        !            23: *                                                                      *
        !            24: *                                                                      *
        !            25: *      Notation: a floating point number is expressed as               *
        !            26: *      MANTISSA * (2 ** EXPONENT).                                     *
        !            27: *                                                                      *
        !            28: *      If this offends more traditional mathematicians, then           *
        !            29: *      please tell me your nomenclature for flonums!                   *
        !            30: *                                                                      *
        !            31: \***********************************************************************/
        !            32: 
        !            33: #import "bignum.h"
        !            34: 
        !            35: /***********************************************************************\
        !            36: *                                                                      *
        !            37: *      Variable precision floating point numbers.                      *
        !            38: *                                                                      *
        !            39: *      Exponent is the place value of the low littlenum. E.g.:         *
        !            40: *      If  0:  low points to the units             littlenum.          *
        !            41: *      If  1:  low points to the LITTLENUM_RADIX   littlenum.          *
        !            42: *      If -1:  low points to the 1/LITTLENUM_RADIX littlenum.          *
        !            43: *                                                                      *
        !            44: \***********************************************************************/
        !            45: 
        !            46: /* JF:  A sign value of 0 means we have been asked to assemble NaN
        !            47:    A sign value of 'P' means we've been asked to assemble +Inf
        !            48:    A sign value of 'N' means we've been asked to assemble -Inf
        !            49:  */
        !            50: struct FLONUM_STRUCT {
        !            51:   LITTLENUM_TYPE *     low;    /* low order littlenum of a bignum */
        !            52:   LITTLENUM_TYPE *     high;   /* high order littlenum of a bignum */
        !            53:   LITTLENUM_TYPE *     leader; /* -> 1st non-zero littlenum */
        !            54:                                /* If flonum is 0.0, leader==low-1 */
        !            55:   long int             exponent; /* base LITTLENUM_RADIX */
        !            56:   char                 sign;   /* '+' or '-' */
        !            57: };
        !            58: 
        !            59: typedef struct FLONUM_STRUCT FLONUM_TYPE;
        !            60: 
        !            61: struct const_FLONUM_STRUCT {
        !            62:   const LITTLENUM_TYPE *       low;    /* low order littlenum of a bignum */
        !            63:   const LITTLENUM_TYPE *       high;   /* high order littlenum of a bignum */
        !            64:   const LITTLENUM_TYPE *       leader; /* -> 1st non-zero littlenum */
        !            65:                                        /* If flonum is 0.0, leader==low-1 */
        !            66:   long int             exponent; /* base LITTLENUM_RADIX */
        !            67:   char                 sign;   /* '+' or '-' */
        !            68: };
        !            69: 
        !            70: typedef struct const_FLONUM_STRUCT const_FLONUM_TYPE;
        !            71: 
        !            72: 
        !            73: /***********************************************************************\
        !            74: *                                                                      *
        !            75: *      Since we can (& do) meet with exponents like 10^5000, it        *
        !            76: *      is silly to make a table of ~ 10,000 entries, one for each      *
        !            77: *      power of 10. We keep a table where item [n] is a struct         *
        !            78: *      FLONUM_FLOATING_POINT representing 10^(2^n). We then            *
        !            79: *      multiply appropriate entries from this table to get any         *
        !            80: *      particular power of 10. For the example of 10^5000, a table     *
        !            81: *      of just 25 entries suffices: 10^(2^-12)...10^(2^+12).           *
        !            82: *                                                                      *
        !            83: \***********************************************************************/
        !            84: 
        !            85: 
        !            86: extern const const_FLONUM_TYPE flonum_positive_powers_of_ten[];
        !            87: extern const const_FLONUM_TYPE flonum_negative_powers_of_ten[];
        !            88: extern const int table_size_of_flonum_powers_of_ten;
        !            89:                                /* Flonum_XXX_powers_of_ten[] table has */
        !            90:                                /* legal indices from 0 to */
        !            91:                                /* + this number inclusive. */
        !            92: 
        !            93: 
        !            94: 
        !            95: /***********************************************************************\
        !            96: *                                                                      *
        !            97: *      Declare worker functions.                                       *
        !            98: *                                                                      *
        !            99: \***********************************************************************/
        !           100: 
        !           101: extern void flonum_multip(
        !           102:     const_FLONUM_TYPE *a,
        !           103:     FLONUM_TYPE *b,
        !           104:     FLONUM_TYPE *product);
        !           105: extern void flonum_copy(
        !           106:     FLONUM_TYPE *in,
        !           107:     FLONUM_TYPE *out);
        !           108: extern int atof_generic(
        !           109:     char **address_of_string_pointer,
        !           110:     const char *string_of_decimal_marks,
        !           111:     const char *string_of_decimal_exponent_marks,
        !           112:     FLONUM_TYPE *address_of_generic_floating_point_number);
        !           113: 
        !           114: 
        !           115: /***********************************************************************\
        !           116: *                                                                      *
        !           117: *      Declare error codes.                                            *
        !           118: *                                                                      *
        !           119: \***********************************************************************/
        !           120: 
        !           121: #define ERROR_EXPONENT_OVERFLOW (2)

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.