Changeset 12535


Ignore:
Timestamp:
03/14/10 19:17:37 (11 years ago)
Author:
ehuelsmann
Message:

Fix returned values from SingleFloat?.getInstance() and
DoubleFloat?.getInstance() for -0.0; -0.0 == 0.0.

Patch by: Douglas Miles (dmiles at users dot sf dot net)

Location:
trunk/abcl/src/org/armedbear/lisp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/DoubleFloat.java

    r12431 r12535  
    5757
    5858    public static DoubleFloat getInstance(double d) {
    59         if (d == 0)
    60             return ZERO;
    61         else if (d == -0.0d )
    62             return MINUS_ZERO;
     59        if (d == 0) {
     60            long bits = Double.doubleToRawLongBits(d);
     61            if (bits < 0)
     62                return MINUS_ZERO;
     63            else
     64                return ZERO;
     65        }
    6366        else if (d == 1)
    6467            return ONE;
  • trunk/abcl/src/org/armedbear/lisp/SingleFloat.java

    r12288 r12535  
    5757
    5858    public static SingleFloat getInstance(float f) {
    59         if (f == 0)
    60             return ZERO;
    61         else if (f == -0.0f )
    62             return MINUS_ZERO;
     59        if (f == 0) {
     60            int bits = Float.floatToRawIntBits(f);
     61            if (bits < 0)
     62                return MINUS_ZERO;
     63            else
     64                return ZERO;
     65        }
    6366        else if (f == 1)
    6467            return ONE;
Note: See TracChangeset for help on using the changeset viewer.