flat assembler
Message board for the users of flat assembler.

Index > Main > multiplication of longs(or even longer numbers)

Author
Thread Post new topic Reply to topic
fredlllll



Joined: 17 Apr 2013
Posts: 56
fredlllll 26 Apr 2013, 09:17
hi there.
some noobish question here: how does the multiplication or division of longs work? i just dont get the code i get from the compiler.
can anyone explain to me, how its done to multiply longs, or numbers with for example 50 byte. is it possible to do this?

i want to make a fixed size big int in assembler (and i want to understand how its done, copying stuff doesnt do it for me)
im trying to make this object oriented. so maybe i will come back with questions about that.

hope i dont annoy you with my noob questions =/
Post 26 Apr 2013, 09:17
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20445
Location: In your JS exploiting you and your system
revolution 26 Apr 2013, 10:15
If you are willing to study a bit then I suggest you search for articles on Arbitrary Precision numbers. And don't forget about the Knuth books.

There is a lot of literature around on how to do various operations upon arbitrary precision numbers.
Post 26 Apr 2013, 10:15
View user's profile Send private message Visit poster's website Reply with quote
alessandro95



Joined: 24 Mar 2013
Posts: 62
alessandro95 26 Apr 2013, 11:23
as bitRAKE told me in another thread there is a nice introduction on x86asm.net, they only deal with multiplication and division of an arbitrary size number by a machine word size number (32 bit in the examples but you can easily adapt them if you are writing 64 bit code), if you need operations between big numbers then I cannot help you :S (but maybe google can Razz)
Post 26 Apr 2013, 11:23
View user's profile Send private message Reply with quote
fredlllll



Joined: 17 Apr 2013
Posts: 56
fredlllll 26 Apr 2013, 14:25
the problem with the one on x86asm.net is, that it only shows the multiplication with 32bit ints. but i want for example multiply 2 1024 bit ints.

@revolution:
well i dont want to buy a book just for that bit of knowledge. but ill look at that arbitrary precision thing.
Post 26 Apr 2013, 14:25
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20445
Location: In your JS exploiting you and your system
revolution 26 Apr 2013, 14:36
fredlllll wrote:
well i dont want to buy a book just for that bit of knowledge. ...
Oh. That is kind of sad actually. The Knuth books have so much more than just that. But anyhow, the Internet can be a second class substitute instead.

Knowledge is one of the most precious things that I hold dear to me.
Post 26 Apr 2013, 14:36
View user's profile Send private message Visit poster's website Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
typedef 26 Apr 2013, 19:55
revolution wrote:
Knowledge is one of the most precious things that I hold dear to me.


How about sharing it heh

So when you die, your knowledge will live on.
Post 26 Apr 2013, 19:55
View user's profile Send private message Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1178
Location: Unknown
HaHaAnonymous 26 Apr 2013, 20:17
[ Post removed by author. ]


Last edited by HaHaAnonymous on 28 Feb 2015, 20:56; edited 1 time in total
Post 26 Apr 2013, 20:17
View user's profile Send private message Reply with quote
alessandro95



Joined: 24 Mar 2013
Posts: 62
alessandro95 27 Apr 2013, 01:31
I do not like the art of assembly but here he explains how to do long integer operations, he uses the algorithm they probably taught you in school, which should be fine for 1024 bit integers but if you are dealing with numbers that are several dozens if not hundreds of thousands of decimal digits long you may want to look at the Schönhage-Strassen algorithm for multiplication and you should find here some useful algorithms for fast divisions.

p.s.
Don't ask me about the algorithm I linked, I only know that is widely used and pretty fast but I cannot understand all the maths involved
Post 27 Apr 2013, 01:31
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20445
Location: In your JS exploiting you and your system
revolution 27 Apr 2013, 04:40
Before getting into the FFT stuff, one might be best going with Karatsuba first for the larger numbers. For many implementations, above ~10000-100000 digits is when FFT becomes an overall win.
Post 27 Apr 2013, 04:40
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.