Much investigation of bignum problems
bignum multiply is still not working, but as bignum read and bignum divide depend on it, it's the problem to hit first.
This commit is contained in:
parent
000ae3c392
commit
0f8bc990f2
9 changed files with 372 additions and 173 deletions
|
|
@ -5,12 +5,12 @@
|
|||
# (right on the boundary)
|
||||
a=1152921504606846975
|
||||
b=1
|
||||
expected='1152921504606846976'
|
||||
output=`echo "(+ $a $b)" | target/psse -v 2 2>psse.log`
|
||||
c=`echo "$a + $b" | bc`
|
||||
expected='t'
|
||||
output=`echo "(= (+ $a $b) $c)" | target/psse -v 2 2>psse.log`
|
||||
|
||||
actual=`echo $output |\
|
||||
tail -1 |\
|
||||
sed 's/\,//g'`
|
||||
tail -1`
|
||||
|
||||
echo -n "adding $a to $b: "
|
||||
if [ "${expected}" = "${actual}" ]
|
||||
|
|
@ -36,8 +36,9 @@ fi
|
|||
# (just over the boundary)
|
||||
a='1152921504606846976'
|
||||
b=1
|
||||
expected='1152921504606846977'
|
||||
output=`echo "(+ $a $b)" | target/psse -v 2 2>psse.log`
|
||||
c=`echo "$a + $b" | bc`
|
||||
expected='t'
|
||||
output=`echo "(= (+ $a $b) $c)" | target/psse -v 2 2>psse.log`
|
||||
|
||||
actual=`echo $output |\
|
||||
tail -1 |\
|
||||
|
|
@ -62,13 +63,15 @@ else
|
|||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
#####################################################################
|
||||
# add a bignum and a smallnum to produce a bignum
|
||||
# (just over the boundary)
|
||||
a='1152921504606846977'
|
||||
b=1
|
||||
expected='1152921504606846978'
|
||||
output=`echo "(+ $a $b)" | target/psse -v 2 2>psse.log`
|
||||
c=`echo "$a + $b" | bc`
|
||||
expected='t'
|
||||
output=`echo "(= (+ $a $b) $c)" | target/psse -v 2 2>psse.log`
|
||||
|
||||
actual=`echo $output |\
|
||||
tail -1 |\
|
||||
|
|
@ -98,8 +101,9 @@ fi
|
|||
# (just over the boundary)
|
||||
a=1
|
||||
b=1152921504606846977
|
||||
expected='1152921504606846978'
|
||||
output=`echo "(+ $a $b)" | target/psse -v 2 2>psse.log`
|
||||
c=`echo "$a + $b" | bc`
|
||||
expected='t'
|
||||
output=`echo "(= (+ $a $b) $c)" | target/psse -v 2 2>psse.log`
|
||||
|
||||
actual=`echo $output |\
|
||||
tail -1 |\
|
||||
|
|
@ -124,12 +128,14 @@ else
|
|||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
#####################################################################
|
||||
# add two bignums to produce a bignum
|
||||
a=10000000000000000000
|
||||
b=10000000000000000000
|
||||
expected='20000000000000000000'
|
||||
output=`echo "(+ $a $b)" | target/psse -v 2 2>psse.log`
|
||||
c=`echo "$a + $b" | bc`
|
||||
expected='t'
|
||||
output=`echo "(= (+ $a $b) $c)" | target/psse -v 2 2>psse.log`
|
||||
|
||||
actual=`echo $output |\
|
||||
tail -1 |\
|
||||
|
|
@ -154,13 +160,15 @@ else
|
|||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
#####################################################################
|
||||
# add a smallnum and a two-cell bignum to produce a three-cell bignum
|
||||
# (just over the boundary)
|
||||
a=1
|
||||
b=1329227995784915872903807060280344576
|
||||
expected='1329227995784915872903807060280344577'
|
||||
output=`echo "(+ $a $b)" | target/psse -v 2 2>psse.log`
|
||||
c=`echo "$a + $b" | bc`
|
||||
expected='t'
|
||||
output=`echo "(= (+ $a $b) $c)" | target/psse -v 2 2>psse.log`
|
||||
|
||||
actual=`echo $output |\
|
||||
tail -1 |\
|
||||
|
|
@ -185,3 +193,36 @@ else
|
|||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
#####################################################################
|
||||
# This currently fails:
|
||||
# (= (+ 1 3064991081731777716716694054300618367237478244367204352)
|
||||
# 3064991081731777716716694054300618367237478244367204353)
|
||||
a=1
|
||||
b=3064991081731777716716694054300618367237478244367204352
|
||||
c=`echo "$a + $b" | bc`
|
||||
expected='t'
|
||||
output=`echo "(= (+ $a $b) $c)" | target/psse -v 2 2>psse.log`
|
||||
|
||||
actual=`echo $output |\
|
||||
tail -1 |\
|
||||
sed 's/\,//g'`
|
||||
|
||||
echo -n "adding $a to $b: "
|
||||
if [ "${expected}" = "${actual}" ]
|
||||
then
|
||||
echo "OK"
|
||||
else
|
||||
echo "Fail: expected '${expected}', got '${actual}'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -n "checking a bignum was created: "
|
||||
grep 'BIGNUM!' psse.log > /dev/null
|
||||
if [ $? -eq "0" ]
|
||||
then
|
||||
echo "OK"
|
||||
else
|
||||
echo "Fail"
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,29 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Not really a unit test, but a check to see where bignum addition breaks
|
||||
|
||||
broken=0
|
||||
i=1152921506900200000
|
||||
# we've already proven we can successfullu get up to here
|
||||
increment=10000
|
||||
|
||||
while [ $broken -eq "0" ]
|
||||
do
|
||||
expr="(+ $i $increment)"
|
||||
# Use sbcl as our reference implementation...
|
||||
expected=`echo "$expr" | sbcl --noinform | grep -v '*'`
|
||||
actual=`echo "$expr" | target/psse | tail -1 | sed 's/\,//g'`
|
||||
|
||||
echo -n "adding $increment to $i: "
|
||||
|
||||
if [ "${expected}" = "${actual}" ]
|
||||
then
|
||||
echo "OK"
|
||||
else
|
||||
echo "Fail: expected '${expected}', got '${actual}'"
|
||||
broken=1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
i=$expected
|
||||
done
|
||||
Loading…
Add table
Add a link
Reference in a new issue