PDA

View Full Version : Big Integer module



Johannes
04-03-2011, 14:19
This is the first complete release of my BigInt module for thinBasic.

All functionality that was in the thinBasic include script is present, along with functions to control conversion between ASCII strings and Big Integers.

Apart from the module DLL the zip file contains a small text file that explains how to get things started, a thinBasic script that tests all keywords and performs integrity checks, and a PDF manual. That manual is what makes the zip file so big, the original OpenOffice document is only 40 kBytes uncompressed.


Future developments

Internal addition, subtraction and multiplication are still in standard PowerBASIC. I will convert these to assembler which should speed up most operations.
Some optimisations will certainly be added for BigInt_Prm and BigInt_Cmb. I will check the other functions to see if they can be optimised as well.
Binary logic (and, or, etc.) and bit stream (set, clear, shift, rotate, etc.) functions will be added. Descriptions of these functions are already in the manual.
If you have any questions or bug reports, or if you have suggestions for new or expanded functions, or would like to see some aliases added (e.g. BigInt_DivideWithRemainder for BigInt_DivRem), create a topic for it in this subforum and I'll see what I can do.

Petr Schreiber
04-03-2011, 14:46
Hi Johannes,

the library itself is very powerful and the documentation is detailed and professionaly presented. Good job!


Petr

P.S. I can see the attachement in first post okay.

Johannes
06-03-2011, 02:48
Found a real doozy, in the internal subtraction subroutine of all places. If the subtracted value is more than one DWord smaller and the first DWord "above" the subtracted value is zero, then it all goes to hell.

The next bit of code should not print anything.


Uses "Console"
Module "BigInt"
Alias String As BigInt
BigInt a,b
String c
a=BigInt_FromString("100000000000000000000000000000000_16")
b=BigInt_FromString("10000000000000000_16")
c=BigInt_ToString(BigInt_Sub(a,b),16)
If c<>"+FFFFFFFFFFFFFFFF0000000000000000_16" Then PrintL "Something is wrong..."
New module and test script in zip file in the "latest release" topic. Please upgrade.

ErosOlmi
06-03-2011, 10:00
New module and test script in zip file. Please upgrade.

Johannes,

just a suggestion: in order not to confuse people, it is a good option to have just one (maybe Sticky) thread where the last version of your module can be found avoiding to attach latest version in many different posts.

Ciao
Eros

Johannes
06-03-2011, 13:41
Eros, that is an excellent idea. I will create a new thread with just the latest release and remove the archives from this one.