Currency Data Type

Purpose

Fixed-point floating-point data type.

Example

Dim name As Currency
Dim name@

Description

Type declaration character is @.

Currency variables are stored as 64-bit (8-byte) numbers in an integer format, scaled by 10,000 to give a fixed-point number with 15 digits to the left of the decimal point and 4 digits to the right. This representation provides a range of:

-922337203685477.5808 (_minCur) to 922337203685477.5807 (_maxCur).

The Currency data type supports up to four digits to the right of the decimal separator and fifteen digits to the left; it is an accurate fixed-point data type suitable for monetary calculations. Floating-point (Single and Double) numbers have much larger ranges than Currency, but can be subject to small rounding errors.

A Currency occupies 64 bit = 8 bytes with at least 7 digits of precision.

Use the Currency data type instead of Single or Double for monetary values. If you specify more than four decimal places in a currency expression, GFA-BASIC 32 rounds to four places before evaluating the expression.

Example

Dim d As Currency = 2.10

Local Currency d1

Local d2@

Const DD = 1@

See Also

Boolean, Byte, Card, Short, Word, Int16, Long, Int, Integer, Int32, Int64, Large, Single, Double, Currency, Date, Handle, String, Variant, Object

{Created by Sjouke Hamstra; Last updated: 04/01/2021 by James Gaite}