• Robert Griesemer's avatar
    math/big: added (internal) Float.form field for easier case distinctions · 363617c7
    Robert Griesemer authored
    This is a fairly significant _internal_ representation change. Instead
    of encoding 0, finite, infinite, and NaN values with special mantissa
    and exponent values, a new (1 byte) 'form' field is used (without making
    the Float struct bigger). The form field permits simpler and faster
    case distinctions. As a side benefit, for zero and non-finite floats,
    fewer fields need to be set. Also, the exponent range is not the full
    int32 range (in the old format, infExp and nanExp were used to represent
    Inf and NaN values and tests for those values sometimes didn't test
    for the empty mantissa, so the range was reduced by 2 values).
    
    The correspondence between the old and new fields is as follows.
    Old representation:
    
    x                 neg      mant         exp
    ---------------------------------------------------------------
    +/-0              sign     empty        0
    0 < |x| < +Inf    sign     mantissa     exponent
    +/-Inf            sign     empty        infExp
    NaN               false    empty        nanExp
    
    New representation (- stands for ignored fields):
    
    x                 neg      mant         exp         form
    ---------------------------------------------------------------
    +/-0              sign     -            -           zero
    0 < |x| < +Inf    sign     mantissa     exponent    finite
    +/-Inf            sign     -            -           inf
    NaN               -        -            -           nan
    
    Client should not be affected by this change.
    
    Change-Id: I7e355894d602ceb23f9ec01da755fe6e0386b101
    Reviewed-on: https://go-review.googlesource.com/6870Reviewed-by: 's avatarAlan Donovan <adonovan@google.com>
    363617c7
decimal.go 6.51 KB