flat assembler
Message board for the users of flat assembler.

 Index > Main > huge decimal number to hexadecimal
Author
 Thread
nooob

Joined: 14 Nov 2008
Posts: 1
nooob 14 Nov 2008, 11:24
hello gurus

how to convert a huge negative or positive 128 bit number or above from decimal to hexadecimal using only 486 32 bit instructions set?
14 Nov 2008, 11:24
vid
Verbosity in development

Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 14 Nov 2008, 11:49
You need to create your own set of bignum routines, capable to add digit to bit number, and capable to multiply big number by 10.

Then you must convert decimal number to bignumr: set big num X to 0, and go from low (last) to high (first) digit of decimal number. For each digit, multiply x by 10, and then add value of digit to x. When you are done with that, converting binary big number to hex is very easy, just one hex digit per 4 bits of big number.

About manipulation with bignums, see this article: http://x86asm.net/articles/working-with-big-numbers-using-x86-instructions/index.html
14 Nov 2008, 11:49
windwakr

Joined: 30 Jun 2004
Posts: 827
windwakr 14 Nov 2008, 13:51
Wouldn't that reverse the number? 12345 would become bignum 54321. In 4bit increments is 1101 0100 0011 0001 which is D431 in hex, but 12345 in hex is 3039. Or am I missing something?
14 Nov 2008, 13:51
Vasilev Vjacheslav

Joined: 11 Aug 2004
Posts: 392
Vasilev Vjacheslav 14 Nov 2008, 14:18
use miracl and do not reinvent the wheel
14 Nov 2008, 14:18
bitRAKE

Joined: 21 Jul 2003
Posts: 3976
Location: vpcmipstrm
bitRAKE 15 Nov 2008, 03:31
Accumulate digits to a larger (like 10^9) base then merge with BIGINT for speed. Wheels should be reinvented because the roads are changing...
15 Nov 2008, 03:31
Vasilev Vjacheslav

Joined: 11 Aug 2004
Posts: 392
Vasilev Vjacheslav 15 Nov 2008, 10:49
i suggest to use square wheels if so
15 Nov 2008, 10:49
bitRAKE

Joined: 21 Jul 2003
Posts: 3976
Location: vpcmipstrm
bitRAKE 16 Nov 2008, 17:50
There are roads where square wheels would be optimal!
16 Nov 2008, 17:50
 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

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

Website powered by rwasa.