Arithmetic with numbers stored in strings

I have a database with numbers stored in the money datatype, for example 11.83

If I extract that from a RecordSet with DoubleValue I’ll get something like 11.83000000001.
If I extract it with StringValue I get a string with “11.83”

However I want to add and subtract these values, without losing precision, so how would I work with these strings without losing precision through conversions to double?

Thanks
Kent

oh, just to forestall some postings, yes, I know why the number shows up as 11.8300000001, the inability of the double type to accurately represent numbers that are not a binary fraction.

BCD arithemetic is one way, but isn’t there a better way ?

Try using the Currency datatype. See http://developer.xojo.com/currency

Nice, thank you :slight_smile:

You could try the BigNumberMBS class in MBS Plugins.
http://www.monkeybreadsoftware.net/pluginpart-bignumber.shtml

[quote=319928:@Kent Sorensen]oh, just to forestall some postings, yes, I know why the number shows up as 11.8300000001, the inability of the double type to accurately represent numbers that are not a binary fraction.

BCD arithemetic is one way, but isn’t there a better way ?[/quote]

For financial apps BCD is likely the best way since they usually behave about how accountants expect (at least in my experience with various languages that supported a BCD type they did)

[quote=319932:@Christian Schmitz]You could try the BigNumberMBS class in MBS Plugins.
http://www.monkeybreadsoftware.net/pluginpart-bignumber.shtml[/quote]
Or with the free plugins from Bob Delaney like the Decimal plugin