diff options
| author | azidar | 2015-08-20 14:19:02 -0700 |
|---|---|---|
| committer | azidar | 2015-08-20 14:19:26 -0700 |
| commit | 5bf451acbe03ecfd6407d7376cbb782ac0dd0f11 (patch) | |
| tree | dddff083fe2e733bec114b34aadae5070714bcc7 /src/main/stanza/bigint2.stanza | |
| parent | 9175d99c622ca9b8c85ff733dbf9f0aa3ec8e266 (diff) | |
Added rsh to BigInt library. Const Prop now works on rsh's on constants. #19.
Diffstat (limited to 'src/main/stanza/bigint2.stanza')
| -rw-r--r-- | src/main/stanza/bigint2.stanza | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/main/stanza/bigint2.stanza b/src/main/stanza/bigint2.stanza index d7376649..4657878a 100644 --- a/src/main/stanza/bigint2.stanza +++ b/src/main/stanza/bigint2.stanza @@ -75,7 +75,7 @@ public defn BigInt (d:Array<Int>, num-bits:Int) : public defmethod get (b:BigInt, index:Int) -> Int : check-index(index) - if index > num-bits(b) : error("Bit index is too high") + if index >= num-bits(b) : error("Bit index is too high") val word-index = index / 32 val bit-index = index % 32 (d(b)[word-index] >> bit-index) & 1 @@ -147,12 +147,9 @@ public defn bit (b:BigInt, index:Int) -> BigInt : b*[0] = b[index] b* -; For now, rsh does not change the number of bits -public defn rsh-unsigned (b:BigInt, amount:Int) -> BigInt : - val b* = BigIntZero(num-bits(b)) - for i in 0 to num-bits(b*) do : - b*[i] = b[i + amount] - b* +public defn rsh (b:BigInt, amount:Int) -> BigInt : + check-index(amount) + bits(b,num-bits(b), amount) |
