Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > 32bit Decimal convertion
2018-10-05 07:02
JackAsser

Registered: Jun 2002
Posts: 1989
32bit Decimal convertion

Anybody got this shitz for 32-bit numbers? http://codebase64.org/doku.php?id=base:hexadecimal_to_decimal_c..
 
... 17 posts hidden. Click here to view all posts....
 
2018-10-05 10:32
JackAsser

Registered: Jun 2002
Posts: 1989
Or I just show the experience points in hex... ;)
2018-10-05 10:33
JackAsser

Registered: Jun 2002
Posts: 1989
Quote: If he is, I could sort of sympathise with that, if it was part of a large project like Eye of the Beholder with zillions of lines of code and someone else had already implemented a 32-bit version of that routine.

I can't sympathise with the spelling of "Convertion" (Conversion) though. ;)


Also not zillions, but just 40688 at the moment (675kb).
2018-10-05 10:35
Krill

Registered: Apr 2002
Posts: 2851
Quoting JackAsser
nope, same there as on Codebase.
Indeed, Codebase has a straight 1:1 rip of the original 6502.org page, without giving proper credit. Not cool, Codebase, not cool.

Quoting JackAsser
Thinking of some simple shift+add with the 1/10 since that is a very simple bitpattern 110011001100110011...
Please elaborate. :)
2018-10-05 10:36
JackAsser

Registered: Jun 2002
Posts: 1989
Quote: You're too lazy to pick any of the 3 approaches and modify the routine for 32-bit numbers? :)

Actually I didn't even bother to look closer on that code posted there but I didn't now and it's meant to be extended.

"The principle should be pretty clear. You can take it out to as many digits as you want."

However it relies on decimal mode being set, something my interrupt handlers can't handle and I'm not willing to fuck timing all over the place.
2018-10-05 10:41
Krill

Registered: Apr 2002
Posts: 2851
You have shitloads of spare memory for lookup tables, right? :) That allows for a very simple and fast approach with 4 8-bit lookups and 3 adds, both times decimal places, or something, i think.
2018-10-05 10:42
JackAsser

Registered: Jun 2002
Posts: 1989
Quote: Quoting JackAsser
nope, same there as on Codebase.
Indeed, Codebase has a straight 1:1 rip of the original 6502.org page, without giving proper credit. Not cool, Codebase, not cool.

Quoting JackAsser
Thinking of some simple shift+add with the 1/10 since that is a very simple bitpattern 110011001100110011...
Please elaborate. :)


Basically you want to do:

int value = 0xdeadbeef;

int digit0 = value%10; value/=10;
int digit1 = value%10; value/=10;
int digit2 = value%10; value/=10;
int digit3 = value%10; value/=10;
int digit4 = value%10; value/=10;
int digit5 = value%10; value/=10;
.
.
.

When rolling your own division the remainder will pop out automatically. Doing a /10 is the same as doing a multiply by 1/10. Multiply by 1/10 is simply a shift+add multiplication with a %110011001100... bitpattern.
2018-10-05 10:43
JackAsser

Registered: Jun 2002
Posts: 1989
Quote: You have shitloads of spare memory for lookup tables, right? :) That allows for a very simple and fast approach with 4 8-bit lookups and 3 adds, both times decimal places, or something, i think.

I actually don't have shitloads of memory left and this code can be dead slow so I'd rather have it tight.
2018-10-05 10:45
Krill

Registered: Apr 2002
Posts: 2851
Then i'd go with the first algorithm, bitwise conversion without any tables or div/mul.
2018-10-05 10:47
JackAsser

Registered: Jun 2002
Posts: 1989
Quote: Then i'd go with the first algorithm, bitwise conversion without any tables or div/mul.

Need to digest it. Don't understand at all how it works atm. :D
2018-10-05 10:52
JackAsser

Registered: Jun 2002
Posts: 1989
Quote: Need to digest it. Don't understand at all how it works atm. :D

Or I just substract billions, and when underflowing, roll back one step and start substracting 100-millions, and then 10-millions etc.. down to ones. Should be resonably fast.

ldx #<-1
:
sec
lda TMP+0
sbc #<(1000000000>>0)
sta TMP+0
lda TMP+1
sbc #<(1000000000>>8)
sta TMP+1
lda TMP+2
sbc #<(1000000000>>16)
sta TMP+2
lda TMP+1
sbc #<(1000000000>>24)
sta TMP+1
inx
bvc :-

etc..
Previous - 1 | 2 | 3 | 4 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Brataccas/HF
Steffan/BOOM!
Flavioweb/🇮🇹HF..
mutetus/Ald ^ Ons
Clayboy
Didi/Laxity
DuncanTwain
Steveboy
Guests online: 119
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Memento Mori  (9.6)
10 Bromance  (9.5)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Rainbow Connection  (9.5)
7 Dawnfall V1.1  (9.5)
8 Quadrants  (9.5)
9 Daah, Those Acid Pil..  (9.5)
10 Birth of a Flower  (9.5)
Top Groups
1 Nostalgia  (9.3)
2 Oxyron  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Webmasters
1 Slaygon  (9.7)
2 Perff  (9.6)
3 Morpheus  (9.5)
4 Sabbi  (9.5)
5 CreaMD  (9.1)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.075 sec.