Board index » delphi » A currency data type or a currency object

A currency data type or a currency object

I am in need of the best way to manipulate currency amounts from
within Delphi. Has anyone developed or knows of a currency data type
or object and associated functions to add, subtract, multiply and
divide without rounding errors. Something along the lines of the
currency data type in Visual Basic would be nice.
Any help anyone could provide me would be greatly appreciated.
Thank you in advance.
John M. Cox
Email Address: Co...@HiWAAY.net
 

Re:A currency data type or a currency object


On Fri, 29 Dec 1995 11:05:04 -0600, John Michael Cox

Quote
<Co...@HiWAAY.net> wrote:
>I am in need of the best way to manipulate currency amounts from
>within Delphi. Has anyone developed or knows of a currency data type
>or object and associated functions to add, subtract, multiply and
>divide without rounding errors. Something along the lines of the
>currency data type in Visual Basic would be nice.
>Any help anyone could provide me would be greatly appreciated.

The Comp type offers 64 bits of exact integer precision. You can use
it with the normal arithmetic operators, and just use an implicit
decimal point that your software keeps track of.

Delphi 32 will have a new type, Currency, which works similarly.
--
Ray Lischner         (li...@tempest-sw.com)
Tempest Software, Corvallis, Oregon, USA

Re:A currency data type or a currency object


John Michael Cox <Co...@HiWAAY.net> wrote:

Quote
>I am in need of the best way to manipulate currency amounts from
>within Delphi. Has anyone developed or knows of a currency data type
>or object and associated functions to add, subtract, multiply and
>divide without rounding errors. Something along the lines of the
>currency data type in Visual Basic would be nice.
>Any help anyone could provide me would be greatly appreciated.
>Thank you in advance.
>John M. Cox
>Email Address: Co...@HiWAAY.net

I usually convert all amounts to cents  for calculation and then
convert back to dollars and cents for 'human' viewing, this avoids
floating point errors as all calculations can be on integers. It also
avoids writing a bcd unit.

.. John

Other Threads