Handling big numbers

I’m in the situation where I have to handle values coming from a database which are 20 digits precision fixed point decimals, that is 12 digits for the integer part and 8 digits for the decimals.

Till now I used the Currency data type, but with the above requirement it doesn’t fit anymore.
Currency can handle 15 digits in the integer part and 4 for decimals max.

Also, being the above values money I can’t afford to use a Double, due to the rounding errors.

As anyone suggestions for an alternative?

http://delaneyrm.com/DecimalPlugin.html

You can do what currency does. Use an int64 and calculate with 8 digits after dot.

So you would convert a number by adding zeros till you have 8 digits behind dot. Than remove dot and take it as int64.

So 1.2 becomes 120000000.

You can do that with your own number class and overloaded operators.

@Michel Bujardet Thanks for the hint. I’m a bit scared to adopt plugins without source code.

@Christian Schmitz Fact is 20 digits in total (that’s what I need) overflows a 64bit number…

Maybe you can contact Bob Delaney to ask if he is willing to sell or share the source.

Otherwise, since what you need goes far beyond anything Xojo supports directly, options seem limited.

I suggested that before in another thread, but it should be possible to process separately integer and decimal. Then the limit is lifted. Of course it means creating methods for Math operations and display, but at first glance it seems doable.

Just for the sake of exploring all possibilities, numeric strings have no limits. But there again, it would require devising math methods. I am also afraid it would be kind of slow.

On OS X you can use NSDecimalNumber

Thanks Antonio, unfortunately I need it for Windows too.