Changeset 8246


Ignore:
Timestamp:
12/16/04 06:34:50 (17 years ago)
Author:
piso
Message:

subtract(int)
isLessThanOrEqualTo(int)

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

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/lisp/Fixnum.java

    r8238 r8246  
    33 *
    44 * Copyright (C) 2002-2004 Peter Graves
    5  * $Id: Fixnum.java,v 1.100 2004-12-11 17:40:38 piso Exp $
     5 * $Id: Fixnum.java,v 1.101 2004-12-16 06:34:50 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    304304    }
    305305
     306    public LispObject subtract(int n)
     307    {
     308        long result = (long) value - n;
     309        if (result >= Integer.MIN_VALUE && result <= Integer.MAX_VALUE)
     310            return new Fixnum((int)result);
     311        else
     312            return new Bignum(result);
     313    }
     314
    306315    public LispObject subtract(LispObject obj) throws ConditionThrowable
    307316    {
     
    458467        // Not reached.
    459468        return false;
     469    }
     470
     471    public boolean isLessThanOrEqualTo(int n)
     472    {
     473        return value <= n;
    460474    }
    461475
  • trunk/j/src/org/armedbear/lisp/LispObject.java

    r8238 r8246  
    33 *
    44 * Copyright (C) 2002-2003 Peter Graves
    5  * $Id: LispObject.java,v 1.104 2004-12-11 17:39:52 piso Exp $
     5 * $Id: LispObject.java,v 1.105 2004-12-16 06:34:02 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    531531    }
    532532
     533    public LispObject subtract(int n) throws ConditionThrowable
     534    {
     535        return subtract(new Fixnum(n));
     536    }
     537
    533538    public LispObject subtract(LispObject obj) throws ConditionThrowable
    534539    {
     
    597602    {
    598603        return isGreaterThan(obj) ? T : NIL;
     604    }
     605
     606    public boolean isLessThanOrEqualTo(int n) throws ConditionThrowable
     607    {
     608        return isLessThanOrEqualTo(new Fixnum(n));
    599609    }
    600610
Note: See TracChangeset for help on using the changeset viewer.