flat assembler
Message board for the users of flat assembler.

 Index > Main > multiplication of longs(or even longer numbers)
Author
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 =/
26 Apr 2013, 09:17
revolution
When all else fails, read the source

Joined: 24 Aug 2004
Posts: 20248
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.
26 Apr 2013, 10:15
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 )
26 Apr 2013, 11:23
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.
26 Apr 2013, 14:25
revolution
When all else fails, read the source

Joined: 24 Aug 2004
Posts: 20248
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.
26 Apr 2013, 14:36
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.

So when you die, your knowledge will live on.
26 Apr 2013, 19:55
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
26 Apr 2013, 20:17
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
27 Apr 2013, 01:31
revolution
When all else fails, read the source

Joined: 24 Aug 2004
Posts: 20248
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.
27 Apr 2013, 04:40
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

 Jump to: Select a forum Official----------------AssemblyPeripheria General----------------MainTutorials and ExamplesDOSWindowsLinuxUnixMenuetOS Specific----------------MacroinstructionsOS ConstructionIDE DevelopmentProjects and IdeasNon-x86 architecturesHigh Level LanguagesProgramming Language DesignCompiler Internals Other----------------FeedbackHeapTest Area

Forum Rules:
 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum