Changeset 4032
- Timestamp:
- 09/23/03 16:32:04 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/j/src/org/armedbear/lisp/Primitives.java
r4029 r4032 3 3 * 4 4 * Copyright (C) 2002-2003 Peter Graves 5 * $Id: Primitives.java,v 1.43 3 2003-09-23 16:25:03piso Exp $5 * $Id: Primitives.java,v 1.434 2003-09-23 16:32:04 piso Exp $ 6 6 * 7 7 * This program is free software; you can redistribute it and/or … … 3943 3943 }; 3944 3944 3945 // ### ash3946 // ash integer count => shifted-integer3947 private static final Primitive2 ASH = new Primitive2("ash") {3948 public LispObject execute(LispObject first, LispObject second)3949 throws ConditionThrowable3950 {3951 BigInteger n;3952 if (first instanceof Fixnum)3953 n = BigInteger.valueOf(((Fixnum)first).getValue());3954 else if (first instanceof Bignum)3955 n = ((Bignum)first).getValue();3956 else3957 throw new ConditionThrowable(new TypeError(first, "integer"));3958 if (second instanceof Fixnum) {3959 int count = Fixnum.getInt(second);3960 if (count == 0)3961 return first;3962 // BigInteger.shiftLeft() succumbs to a stack overflow if count3963 // is Integer.MIN_VALUE, so...3964 if (count == Integer.MIN_VALUE)3965 return n.signum() >= 0 ? Fixnum.ZERO : new Fixnum(-1);3966 return number(n.shiftLeft(count));3967 }3968 if (second instanceof Bignum) {3969 BigInteger count = ((Bignum)second).getValue();3970 if (count.signum() > 0)3971 throw new ConditionThrowable(new LispError("can't represent result of left shift"));3972 if (count.signum() < 0)3973 return n.signum() >= 0 ? Fixnum.ZERO : new Fixnum(-1);3974 Debug.bug(); // Shouldn't happen.3975 }3976 throw new ConditionThrowable(new TypeError(second, "integer"));3977 }3978 };3979 3980 3945 // ### expt 3981 3946 // expt base-number power-number => result
Note: See TracChangeset
for help on using the changeset viewer.