flat assembler
Message board for the users of flat assembler.

Index > Main > huge decimal number to hexadecimal

Author
Thread Post new topic Reply to topic
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?
Post 14 Nov 2008, 11:24
View user's profile Send private message Reply with quote
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
Post 14 Nov 2008, 11:49
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
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?
Post 14 Nov 2008, 13:51
View user's profile Send private message Reply with quote
Vasilev Vjacheslav



Joined: 11 Aug 2004
Posts: 392
Vasilev Vjacheslav 14 Nov 2008, 14:18
use miracl and do not reinvent the wheel
Post 14 Nov 2008, 14:18
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4020
Location: vpcmpistri
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...
Post 15 Nov 2008, 03:31
View user's profile Send private message Visit poster's website Reply with quote
Vasilev Vjacheslav



Joined: 11 Aug 2004
Posts: 392
Vasilev Vjacheslav 15 Nov 2008, 10:49
i suggest to use square wheels if so Smile
Post 15 Nov 2008, 10:49
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4020
Location: vpcmpistri
bitRAKE 16 Nov 2008, 17:50
There are roads where square wheels would be optimal! Razz
Post 16 Nov 2008, 17:50
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.