Luiz Paulo Gama Barreto wrote:
>
> Hi all,
> I'm wondering about the best format to work with currencies.
> It would be a float format? Or maybe work with the values in cents, in a ULong
>format,
Work with the values in cents (fixed-point math with respect to
dollars). The concept here is to use integers, with implied decimal
points. For example, suppose you wanted to find
4.00 x 0.60
Which is equivalent to:
400 60 24000
--- x --- = --------- = 2.4
100 100 (100 x 100)
HINT: Imagine decimal points painted in, two digits from the right.
So, all you need to do it accept input from a field. Multiply the
number by your ScaleFactor (100 in the above example) to turn it into a
fixed-point integer. Perform your calculation (adjusting it as shown
below). Finally, dividing it by your Scale Factor.
Operation Adjustment
Add/Subtract No Adjustment required
Multiply Divide by ScaleFactor
Divide Multiply by ScaleFactor
--
___________________________________________________________________
dpw Designs http://www.pe.net/firm/dpw-designs
mailto:[EMAIL PROTECTED]