« MBS Filemaker Plugin,… | Home | FileMaker Magazin 201… »

Currency Data Type

Xojo features a data type called currency. It is used for storing currency values and uses internally a 64bit value. As 4 digits are reserved for right of the dot, the 1.0 value is stored internally as 10000. When converting between double and integer, values are divided/multiplied by 10000.

There is a problem:
Double values are only precise for 15 digits, so having a big value like 123456789012345.1234 in a currency will not work correctly, as this can't be stored in a double. You get 123456789012345.1136. There are rounding issues.

But some of use need to work with huge numbers and functions like val() internally use double, so there are rounding issues with parsing.

For next plugin we'll add a function CurrencyValueMBS to fix that. Our CurrencyValueMBS function will return currency values parsed up to "+922337203685477.5807" just fine. If value is out of range, we raise an exception, so you can track down errors.
03 09 14 - 21:49