Changeset 8274


Ignore:
Timestamp:
12/20/04 13:20:15 (16 years ago)
Author:
piso
Message:

add(int n)

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

Legend:

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

    r8269 r8274  
    33 *
    44 * Copyright (C) 2002-2004 Peter Graves
    5  * $Id: Fixnum.java,v 1.104 2004-12-19 15:15:21 piso Exp $
     5 * $Id: Fixnum.java,v 1.105 2004-12-20 13:19:43 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    280280            return new Fixnum(value - 1);
    281281        return new Bignum((long) value - 1);
     282    }
     283
     284    public LispObject add(int n)
     285    {
     286        long result = (long) value + n;
     287        if (result >= Integer.MIN_VALUE && result <= Integer.MAX_VALUE)
     288            return new Fixnum((int)result);
     289        else
     290            return new Bignum(result);
    282291    }
    283292
  • trunk/j/src/org/armedbear/lisp/LispObject.java

    r8273 r8274  
    33 *
    44 * Copyright (C) 2002-2003 Peter Graves
    5  * $Id: LispObject.java,v 1.110 2004-12-20 01:51:41 piso Exp $
     5 * $Id: LispObject.java,v 1.111 2004-12-20 13:20:15 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    536536    }
    537537
     538    public LispObject add(int n) throws ConditionThrowable
     539    {
     540        return add(new Fixnum(n));
     541    }
     542
    538543    public LispObject add(LispObject obj) throws ConditionThrowable
    539544    {
Note: See TracChangeset for help on using the changeset viewer.