BCD

BlitzMax Forums/BlitzMax Beginners Area/BCD

Shortwind(Posted 2010) [#1]
Has anyone created a BCD mod for Blitzmax? Or does anyone have any BCD code they have created for Blitzmax?

I've searched the forums, and couldn't find anything for BCD. If I missed it I appologize.


Who was John Galt?(Posted 2010) [#2]
Not that I know of. What do you want to do with it, exactly?


Shortwind(Posted 2010) [#3]
Calculate stuff. :), sorry, couldn't resist.

Seriously, might seem stupid to some, but I want to use it in a calculator type program I'm writing. Mainly because floats and doubles do not have near enough precision on either the left side, nor the right side, for what I require.

I may have to resort to using GMP rationals internally, then figuring out a good conversion routine to decimal later.

Brucey has made so many other mods, I was just hoping that I'd missed something and the BCD had already been implemented.

Thanks.


Who was John Galt?(Posted 2010) [#4]
I wasn't trying to imply it was stupid. I simply needed to understand what you're after before I could offer a possible solution.

BCD as I understand it is pretty much for display of numbers. I would be very surprised if there is anything out there implementing math functions with it.

Try Googling something like 'extended precision arithmetic'. There is unlikely to be anything in Blitz, but you could use a dll or find some C code which is fairly easy to link in with Max.

I have no idea what a GMP rational is?


xlsior(Posted 2010) [#5]
Brucey has a mod that can deal with arbitrary precision numbers and mathematics... Don't remember the name, though.


Floyd(Posted 2010) [#6]
Just search for the word "precision".

Be warned that these things are always awkward. They don't integrate with BlitzMax the way they do with C++. You can't just drop in a new module and have new numeric types and operators. So if you want an expression a+b*c you have to parse it yourself and write something like Add( a, Mul( b, c ) ).


xlsior(Posted 2010) [#7]
Brucey's arbitrary precision math library is here:
http://maxmods.googlecode.com/files/mapm_1_00_src.zip

Brucey's math expression evaluator:
http://maxmods.googlecode.com/files/muparser_1_00_src.zip

Perhaps you can combine the two to accomplish what you want?


Brucey(Posted 2010) [#8]
And there's a module for GMP, which does the same kind of things as MAPM.


Shortwind(Posted 2010) [#9]
Thanks all for the replies. It seems, after doing some thinking and searching, that there appears to be serveral implementations of the "Decimal" type in various languages. I'll have to do some more research on this. But my past experience with Microsoft's "Decimal" does not carry any good fuzzy feelings.

LOL, it's just another of my acts of futility I suppose.