After Dan's challenge (the division of the two ridiculously large integers) I started working on proper Big Integer functionality and I've had it sitting on my hard drive for some time now. I've documented it somewhat, added a test and example program, and here it is for those of you who, like me, can't do with just Quad integers.
Big Integers are what the name says: big. In thinBasic the largest integer data type is Quad: signed 64-bit integers. Although the numbers you can describe in those 64 bits are huge, sometimes they're not huge enough. Which is where BigInt comes in.
The size of a BigInt is limited by only three things: (1) your computer's memory, (2) thinBasic's "limit" of 2GB for a string, and (3) your patience. Make no mistake, number three could be the killer. This is written in straight thinBasic, not assembler, and although you will get a result, you may have to wait for a while. But do not despair: calculating the 13th root of a 200-digit number (included as an example) takes 0.0542 seconds on my computer.
I've added as many functions dealing with integers as I could come up with. I haven't gone the way of stuff like Graham's Number but if you want to know the two millionth Fibonacci number, or the factorial of your birthday, here's your chance.
The source code contains minimal comments (basically a short description of the function) and that's it. I did not document the code itself, mainly because I "get" the stuff that I programmed but also because I would be giving a course in mathematics and binary arithmetic if I did. Not for free Chester.
Anyway, see the attached and the small documentation file. (Had to zip that because I got an upload error for the file.) If you have some questions about how to use it all, have a look at the test and example scripts. If that doesn't help you, ask here and you may receive.
Have fun with it. I did.
Bookmarks