Changeset 12951


Ignore:
Timestamp:
10/04/10 13:11:12 (12 years ago)
Author:
ehuelsmann
Message:

Signal a condition when coercing a Ratio to any float type or when
coercing a double-float to a single-float where the original value
is too big to fit the target type.

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

Legend:

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

    r12288 r12951  
    182182    public float floatValue()
    183183    {
     184        float result = (float) doubleValue();
     185        if (Float.isInfinite(result) && TRAP_OVERFLOW)
     186            type_error(this, Symbol.SINGLE_FLOAT);
     187
    184188        return (float) doubleValue();
    185189    }
     
    218222            d = d.shiftRight(1);
    219223        }
     224        if (Double.isInfinite(result) && TRAP_OVERFLOW)
     225            type_error(this, Symbol.DOUBLE_FLOAT);
     226
    220227        return negative ? -result : result;
    221228    }
  • trunk/abcl/src/org/armedbear/lisp/SingleFloat.java

    r12535 r12951  
    630630        if (obj instanceof SingleFloat)
    631631            return (SingleFloat) obj;
    632         if (obj instanceof DoubleFloat)
    633             return new SingleFloat((float)((DoubleFloat)obj).value);
     632        if (obj instanceof DoubleFloat) {
     633            float result = (float)((DoubleFloat)obj).value;
     634            if (Float.isInfinite(result) && TRAP_OVERFLOW)
     635                type_error(obj, Symbol.SINGLE_FLOAT);
     636
     637            return new SingleFloat(result);
     638        }
    634639        if (obj instanceof Bignum)
    635640            return new SingleFloat(((Bignum)obj).floatValue());
Note: See TracChangeset for help on using the changeset viewer.