• Robert Griesemer's avatar
    go/constant: switch to floating-point representation when fractions become too large · d0c17461
    Robert Griesemer authored
    Use two internal representations for Float values (similar to what is done
    for Int values). Transparently switch to a big.Float representation when
    big.Rat values become unwieldy. This is almost never needed for real-world
    programs but it is trivial to create test cases that cannot be handled with
    rational arithmetic alone.
    
    As a consequence, the go/constant API semantics changes slightly: Until now,
    a value could always be represented in its "smallest" form (e.g., float values
    that happened to be integers would be represented as integers). Now, constant
    Kind depends on how the value was created, rather than its actual value. (The
    reason why we cannot automatically "normalize" values to their smallest form
    anymore is because floating-point numbers are not exact in general; and thus
    normalization is often not possible in the first place, or would throw away
    precision when it is not desired.) This has repercussions as to ho...
    d0c17461
go1.1.txt 2.56 MB