Changeset 4036
- Timestamp:
- 09/23/03 17:09:39 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/j/src/org/armedbear/lisp/ash.java
r4030 r4036 3 3 * 4 4 * Copyright (C) 2003 Peter Graves 5 * $Id: ash.java,v 1. 1 2003-09-23 16:31:03piso Exp $5 * $Id: ash.java,v 1.2 2003-09-23 17:09:39 piso Exp $ 6 6 * 7 7 * This program is free software; you can redistribute it and/or … … 36 36 throws ConditionThrowable 37 37 { 38 if (first instanceof Fixnum && second instanceof Fixnum) { 39 int count = ((Fixnum)second).getValue(); 40 if (count == 0) 41 return first; 42 long n = ((Fixnum)first).getValue(); 43 if (n == 0) 44 return first; 45 if (count < -32) { 46 // Right shift. 47 return n >= 0 ? Fixnum.ZERO : Fixnum.MINUS_ONE; 48 } 49 if (count <= 32) 50 return number(count > 0 ? (n << count) : (n >> -count)); 51 } 38 52 BigInteger n; 39 53 if (first instanceof Fixnum) … … 50 64 // is Integer.MIN_VALUE, so... 51 65 if (count == Integer.MIN_VALUE) 52 return n.signum() >= 0 ? Fixnum.ZERO : new Fixnum(-1);66 return n.signum() >= 0 ? Fixnum.ZERO : Fixnum.MINUS_ONE; 53 67 return number(n.shiftLeft(count)); 54 68 } … … 58 72 throw new ConditionThrowable(new LispError("can't represent result of left shift")); 59 73 if (count.signum() < 0) 60 return n.signum() >= 0 ? Fixnum.ZERO : new Fixnum(-1);74 return n.signum() >= 0 ? Fixnum.ZERO : Fixnum.MINUS_ONE; 61 75 Debug.bug(); // Shouldn't happen. 62 76 }
Note: See TracChangeset
for help on using the changeset viewer.