Skip to content

Decimal

See Also: Declaring Variables, Variable Declaration Commands, Struct, Currency, Number

Purpose

Declares one or more Decimal variables.

Syntax

To declare decimal variables

Decimal {identifier} [{identifier}]

Where:

  • {identifier} is the name of a new Decimal variable. The first {identifier} is required.
  • {identifier} may be between 1 and 4096 characters in length, must start with a letter, and may not contain spaces. Recommended characters are 0-9, a-z, A-Z, and _ (underscore).

To declare array variables of type Decimal

Decimal {dimension-list} {identifier} [{identifier}]

Where:

  • {dimension-list} is a list of one or more array dimensions for the array. A dimension list is declared using square brackets []. One pair of brackets is used to declare each dimension. If the array is static, then you must specify the static size of each dimension between each pair of brackets, i.e., [{size}]. For more information about declaring arrays, refer to Array Variable Assignments.
  • {identifier} may be between 1 and 4096 characters in length, must start with a letter, and may not contain spaces. Recommended characters are 0-9, a-z, A-Z, and _ (underscore).

What It Does

The Decimal command declares Decimal variables, in the range of -9999999999999999.9999999999999999 to 9999999999999999.9999999999999999 (-9,999,999,999,999,999.9999999999999999 to 9,999,999,999,999,999.9999999999999999).

Internally, Decimal is a fixed point variable with up to 32 significant digits - 16 to the left of the decimal point and 16 to the right of the decimal point.

The Decimal type is compatible for storing SQL data of the Decimal or Numeric types.

Multiple variables may be declared on one command line, with their names separated from each other by spaces.

Example

Procedure DoTest
    Decimal decMyVar
    Move 10000.999999999999 To decMyVar
End_Procedure

This example declares one variable of type Decimal, named decMyVar, and initializes it.

Decimal[] decSharePrices

This example declares one dynamic array variable, named decSharePrices, containing an undefined number of elements of type Decimal.

Decimal[5] decSharePrices

This example declares one static array variable, named decSharePrices, containing 5 elements of type Decimal.

Decimal[][3] decSharePrices

This example creates a two-dimensional dynamic array variable named decSharePrices, containing an undefined number of elements of type Decimal. Conceptually, this represents a rectangular array with an undefined number of rows, each of 3 columns.

You can declare dynamic multi-dimensional arrays where all dimensions are dynamic; these are called jagged arrays.

Notes

  • If you need to define a global Decimal variable, you should use the global_variable command to do so.