> I need to calculate with values with 9 decimals.
Use floating-point types, such as 'float' or 'double'.
> I thought the type "Currency" is suiteable for my needs.
Nope, not even close. Please read the documentation more carefully:
"Currency is a C++ class that implements the Delphi Currency data type.
Currency inherits a val data member declared as int64 that holds the
currency value. The range of possible currency values is
922337203685477.5808 to 922337203685477.5807. Use Currency to hold monetary
values."
> I read thet this type only supports 4 decimales.
Correct.
> Later I saw in the BCB2007 help that exists a variable
> "CurrencyDecimals". The help file says that this is the variable
> to set the count of values in a currency value. Does this
> mean the type "Currency"?
No. It it only used when using the "m" specifier in one of the Format...()
functions to create a string value that contains a currency amount in it.
> In other words can I set with this variable the count of
> decimales in a currency type?
No.
Gambit
Remy Lebeau (TeamB) schrieb:
Remy Lebeau (TeamB) schrieb:
You may want to look at an arbitrary/multiple precision library such as GMP.
[Disclaimer: I've never used it and don't know if it will work with BCB.]
-Eliot
Generally, if you care about the accuracy, you'll want to hold the
values and do the calculations in an integer type and then handle the
decimal point when doing input and output.
This is commonly done when handling currency amounts in situations where
even losing a tenth of a cent could be unacceptable. Float and double
are unsuitable for this. Floating point types are approximations. Early
TurboPascal had a variant which used BCD, but an array of int wrapped in
a class will be more efficient. So it is understandable that you
considered the Currency type. But you may end up writing your own class.
fp