The MASM Forum

General => The Laboratory => Topic started by: NoCforMe on September 24, 2022, 07:21:52 AM

Title: Bignums?
Post by: NoCforMe on September 24, 2022, 07:21:52 AM
Anyone know anything about bignums?

Specifically, looking for actual implementations in assembler (or in C or some other translatable language), or even a good conceptual explanation.

Just found out about this technique. (Lets you handle numbers of any arbitrary size without being limited by the size of your registers.)
Title: Re: Bignums?
Post by: zedd151 on September 24, 2022, 08:05:11 AM
From dedndave "Ling Long Kai Fang Bignum to ASCII"
http://masm32.com/board/index.php?topic=222.msg978#msg978 (http://masm32.com/board/index.php?topic=222.msg978#msg978)


Something like this?
A search here for "Bignum" will yield some more results


I also have 'Ascii Adder' that I used for my fibonacci generator.
http://masm32.com/board/index.php?topic=7262.msg79593#msg79593 (http://masm32.com/board/index.php?topic=7262.msg79593#msg79593)
Adds ascii decimal text strings of virtually any length (depending on amount of memory allocated of course)...
Title: Re: Bignums?
Post by: NoCforMe on September 24, 2022, 08:48:05 AM
Um, maybe. Not sure that's the same thing, and not quite ready to delve into that code. But it might be that stuff.
Title: Re: Bignums?
Post by: zedd151 on September 24, 2022, 08:49:04 AM
What do you need it for, what data type?
And, does it have to be fast?
At any rate I think there are still a few math nerds enthusiast members heer who may be able to help.
Title: Re: Bignums?
Post by: zedd151 on September 24, 2022, 09:01:01 AM
a couple more links (from giggle)

A Verified Bignum implementation in x86-64 Machine Code (https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwiKkqqMgaz6AhVAkGoFHbCnBTEQFnoECAoQAQ&url=https%3A%2F%2Fwww.cse.chalmers.se%2F~myreen%2Fcpp13.pdf&usg=AOvVaw2DjxBqwuWo4B78Il2h6xmY) a pdf


working-with-big-numbers-using-x86-instructions (https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwiKkqqMgaz6AhVAkGoFHbCnBTEQFnoECAkQAQ&url=http%3A%2F%2Fx86asm.net%2Farticles%2Fworking-with-big-numbers-using-x86-instructions%2F&usg=AOvVaw1GUpYxnSr0fZn5sT4zocD3)


Not sure if this might be what you are after
Title: Re: Bignums?
Post by: NoCforMe on September 24, 2022, 09:28:59 AM
Thanks--that's exactly the sort of stuff I was looking for. I found that scholarly PDF myself, worth looking at. Also found a complete implementation guide (https://www.exploringbinary.com/correct-decimal-to-floating-point-using-big-integers/) (descriptive text, not code), for converting decimal #s to floating-point, which is what I'm interested in at the moment. Interesting stuff.
Title: Re: Bignums?
Post by: jj2007 on September 24, 2022, 10:30:34 AM
You might search the forum (http://masm32.com/board/index.php?action=search;advanced;search=) for REAL16 or QuadMath, if that's precise enough.
Title: Re: Bignums?
Post by: NoCforMe on September 24, 2022, 12:20:39 PM
No, I want bignums. Gigantic, humongous, gargantuan #s. "Arbirtary precision".
Title: Re: Bignums?
Post by: zedd151 on September 24, 2022, 02:20:34 PM
When I was working on ascii adder, I had made a wisecrack to dedndave about making an ascii subtractor , ascii multiplier, and ascii divider.
Of course I didn't complete that series but if I did, the next in line would have been ascii subtractor.
With those two, it's theoretically possible to do multiplication and division albeit longhand. And it doesn't have to be done with ascii text, could be data with adjustments of course. For floats, just keep good track of the decimal places.  :biggrin:
Sounds like a phun coding exercise. Perfect for the Laboratory. Any takers?
If I ever clear my slate of current projects, I might continue work in this vein with ascii subtractor.  :cool:  dedndave, jimg (helped with its use in the aforementioned fibonacci generator), and rrr314159 (iirc) were instrumental in my work on ascii adder giving some tips. That's when I learned of dedndaves Ling Long Kai Fang library btw.
Title: Re: Bignums?
Post by: NoCforMe on September 24, 2022, 02:38:08 PM
That stuff makes my head hurt.
Title: Re: Bignums?
Post by: daydreamer on September 24, 2022, 07:29:22 PM
Impressive code by raymond with bigness on huge 2^64 fibonnaci
http://masm32.com/board/index.php?topic=9773.msg107857#msg107857