PreviousUpNext

15.4.680  src/lib/compiler/src/fconst/ieee-float-constants.pkg

## ieee-float-constants.pkg

# Compiled by:
#     src/lib/compiler/core.sublib



# Support for IEEE floating-point constants
# Double precision format (for normalized numbers):
#   Bias = 1023.
#   Exponent = 11 bits.
#   Range of exponent = [1..2046]
#   Mantissa = 52 (+1) bits.
#   Value = (-1)^s * 2^(e-1023) * 1.f



###               "Everything you can imagine is real."
###
###                              -- Pablo Picasso



package ieee_float_constants
    =
    slow_portable_floating_point_constants_g (
        #
        package {
            significant = 53; #  52 + redundant 1 bit 

            minexp = -1021;
            maxexp =  1024;

            itow = unt::from_int;
            wtoi = unt::to_int_x;

            fun transreal (sign, frac, expression)
                =
                if (frac (0, 1) == 0) 
                    #
                    if   (sign==0)   "\x00\x00\x00\x00\x00\x00\x00\x00";
                    else             "\x80\x00\x00\x00\x00\x00\x00\x00";
                    fi;
                else
                     implode
                        [char::from_int (wtoi 
                           (unt::bitwise_or (unt::(<<) (itow sign, 0u7), 
                                     unt::(>>) (itow (expression+1022), 0u4)))),
                         char::from_int (wtoi 
                           (unt::bitwise_and (0u255, 
                                      unt::bitwise_or (unt::(<<) (itow (expression+1022), 0u4),
                                               itow (frac (1, 4)))))),
                         char::from_int (frac (5, 8)),
                         char::from_int (frac (13, 8)),
                         char::from_int (frac (21, 8)),
                         char::from_int (frac (29, 8)),
                         char::from_int (frac (37, 8)),
                         char::from_int (frac (45, 8))];
                fi;

        }
    );



## Copyright 1989 by AT&T Bell Laboratories 
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext