From d8991e8823dec702a5da41938fc47ba453a75c9c Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Fri, 18 Jan 2019 14:09:26 +0000 Subject: [PATCH] H'mmm. But although two-cell bignums work, n-cell do not. Both add and print fail with numbers larger than 2^120 --- unit-tests/bignum-add.sh | 33 +++++++++++++++++++++++++++++++++ unit-tests/bignum-print.sh | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/unit-tests/bignum-add.sh b/unit-tests/bignum-add.sh index 678b766..a4244ee 100644 --- a/unit-tests/bignum-add.sh +++ b/unit-tests/bignum-add.sh @@ -153,3 +153,36 @@ else echo "Fail" 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` + +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 + +1329227995784915872903807060280344576 diff --git a/unit-tests/bignum-print.sh b/unit-tests/bignum-print.sh index c030f37..69d2d24 100644 --- a/unit-tests/bignum-print.sh +++ b/unit-tests/bignum-print.sh @@ -38,7 +38,7 @@ fi ##################################################################### # definitely a bignum -expected='2305843009213693952' +expected='1329227995784915872903807060280344577' output=`echo "(progn (print $expected) nil)" | target/psse` actual=`echo $output |\