Results 1 to 10 of 15

Thread: Big Integer Math include file

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Member Johannes's Avatar
    Join Date
    Nov 2010
    Location
    Wuustwezel, Belgium
    Age
    56
    Posts
    95
    Rep Power
    25

    Big Integer Math include file

    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.
    Attached Files Attached Files
    Boole and Turing, help me!

    Primary programming: 200 MHz ARM StrongARM, RISC OS 4.02, BASIC V, ARM assembler.
    Secondary programming: 3.16 GHz Intel Core 2 Duo E8500, Vista Home Premium SP2, thinBasic, x86 assembler.

  2. #2
    Member Johannes's Avatar
    Join Date
    Nov 2010
    Location
    Wuustwezel, Belgium
    Age
    56
    Posts
    95
    Rep Power
    25

    Almost forgot...

    I've put in an Easter Egg.

    The people most likely to find this Easter Egg are code browsers and people with thick fingers (ie. people making typing errors). If you find the Easter Egg let me know what you think of it. If you understand what it is, that is.

    I'll give you one small hint (completely useless, so I might as well give it), and because 13 is my favourite number, this is it:

    13 is 13 long
    Boole and Turing, help me!

    Primary programming: 200 MHz ARM StrongARM, RISC OS 4.02, BASIC V, ARM assembler.
    Secondary programming: 3.16 GHz Intel Core 2 Duo E8500, Vista Home Premium SP2, thinBasic, x86 assembler.

  3. #3
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404
    Can't wait for someone to solve the Easter Egg.

    Here is the only thing, I can find.
    http://primes.utm.edu/curios/page.php/4294967295.html

    Another thing that I saw that I have no idea is "42_13"
    42 the answer to the universe and everything alongside your favorite number 13

  4. #4
    thinBasic MVPs danbaron's Avatar
    Join Date
    Jan 2010
    Location
    California
    Posts
    1,378
    Rep Power
    152
    I downloaded all of your stuff, Johannes.

    Boy, you did a lot of work.

    I don't understand it, but it looks good to me.

    I like the 13th root calculation.

    And, I like the test of all of your functions. That test code is really something.

    And, I like your documentation. Some of those functions, like, BigInt_Nrt, look amazing.

    Humbly,
    Dan
    "You can't cheat an honest man. Never give a sucker an even break, or smarten up a chump." - W.C.Fields

  5. #5
    Member Johannes's Avatar
    Join Date
    Nov 2010
    Location
    Wuustwezel, Belgium
    Age
    56
    Posts
    95
    Rep Power
    25
    Quote Originally Posted by kryton9 View Post
    Another thing that I saw that I have no idea is "42_13"
    42 the answer to the universe and everything alongside your favorite number 13
    That's in the test function. And of course that's straight out of Douglas Adams' Hitch-Hiker's Guide to the Galaxy.

    When they find out the Answer to Life, the Universe and Everything is '42' they build Earth (the planet) to find out what the question is. In the end they try to find the question using Scrabble tiles. The tiles run out but what they get is:

    What do you get if you multiply six and nine?

    Someone, later, suggested that if they had had enough tiles the complete question would have had after that: "in base thirteen".

    It's just a test case. It's not the Easter Egg. The Easter Egg is in the main code and the hint is of no help at all finding it. Only when you've found it will you understand what the hint means.
    Boole and Turing, help me!

    Primary programming: 200 MHz ARM StrongARM, RISC OS 4.02, BASIC V, ARM assembler.
    Secondary programming: 3.16 GHz Intel Core 2 Duo E8500, Vista Home Premium SP2, thinBasic, x86 assembler.

  6. #6
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    I too do not understand the details but this is a huge and great work !
    Thank you very much.

    It also seems perfect for a compiled thinBasic module that would burst execution speed by a factor of 100 or even more.
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  7. #7
    Member Johannes's Avatar
    Join Date
    Nov 2010
    Location
    Wuustwezel, Belgium
    Age
    56
    Posts
    95
    Rep Power
    25

    A proper hint for the Easter Egg...

    Otherwise some poor soul will have to go through the code line by line. Here is a proper hint and it should lead you directly to the Easter Egg.

    all your base IS belong to us

    And that's all I'm going to say about it.
    Boole and Turing, help me!

    Primary programming: 200 MHz ARM StrongARM, RISC OS 4.02, BASIC V, ARM assembler.
    Secondary programming: 3.16 GHz Intel Core 2 Duo E8500, Vista Home Premium SP2, thinBasic, x86 assembler.

Similar Threads

  1. Include file for GDI/GPI+?
    By Michael Hartlef in forum General
    Replies: 4
    Last Post: 20-03-2010, 11:57
  2. 3D Vector Math include file.
    By D.J.Peters in forum Math scripts
    Replies: 5
    Last Post: 11-03-2010, 08:02

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •