aboutsummaryrefslogtreecommitdiff
path: root/bigtest.c
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2016-01-12 07:42:30 -0500
committerB. Watson <yalhcru@gmail.com>2016-01-12 07:42:30 -0500
commit854aaed7643cc2224987738f04384f884d1084d5 (patch)
treef9b4a019a5c859719678bb523ecc1786df665229 /bigtest.c
parentf90842d4decc6f9453e53785174c73674dc86a51 (diff)
downloadtaipan-854aaed7643cc2224987738f04384f884d1084d5.tar.gz
some FP wrappers and test code, not very good yet
Diffstat (limited to 'bigtest.c')
-rw-r--r--bigtest.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/bigtest.c b/bigtest.c
new file mode 100644
index 0000000..f6b2551
--- /dev/null
+++ b/bigtest.c
@@ -0,0 +1,44 @@
+#include <stdio.h>
+#include <peekpoke.h>
+
+#include "bignum.h"
+
+unsigned long values[] = {
+ 123456789L,
+ 12345678L,
+ 1234567L,
+ 123456L,
+ 65536L,
+ 65535L,
+ 4294966190L, /* works, (2**32-1)-1105 */
+ 4294967295L,
+ 665,
+ 78,
+ 1,
+ 0
+};
+
+int main(void) {
+ char i, j;
+ unsigned long l = 123456789L; // 075bcd15, or 52501 + 256 * 1883
+ bignum(b);
+
+ /*
+ ulong_to_big(l, b);
+ for(i=0; i<6; i++)
+ printf("%02x ", b[i]);
+ */
+
+ POKEW(19,0);
+ for(i=0; i < (sizeof(values)) / (sizeof(long)); i++) {
+ l = values[i];
+ printf("%lu: ", l);
+ ulong_to_big(l, b);
+ l = 666L;
+ j = big_to_ulong(b, &l);
+ printf("%d %lu\n", j, l);
+ }
+
+ printf("%d\n", PEEK(20)+256*PEEK(19));
+hang: goto hang;
+}