Hi, in my application i have certain amounts of money which are stored in an object with an attribute of datatype 'currency'. I expected this datatype to have two decimals behind the seperator, but now I notice that calculated amounts have several decimals behind the seperator. Problem When someone makes an export to excel, Excel presents for instance Amount A | 833,23 Amount B | 833,23 The actual value of the cell is 833,232806911794 Now when you perform a sum on the second column, the calculation presented in excel becomes: 1.666,47 Where I expected 1.666,46 Question Do I have to include a function on every commit of this object to force the amount having only 2 digits, or is this a bug in the Mendix Agile Business Platform™ ? Should the platform handle this in the excel export? The reason I choose this datatype was because I thought this stuff was handled for me. What are the differences between, or the consequenses of, selecting datatype Currency instead of float?
It looks as if Mendix does indeed use a floating point data type to store the currency, so you will get rounding errors (google "why are my floating point" or for a very technical explanation go to http://download.oracle.com/docs/cd/E19957-01/806-3568/ncg_goldberg.html).
The usual method to prevent this is to store and calculate in integers and only when displaying (or exporting, in your case), do the division by 100. I'm not sure how/if this would work in Mendix, it requires some investigation. Search the forum for 'currency'.