Decimal support in DataWindow expressions

Decimal datatypes are supported in the DataWindow, but in previous releases of DataWindow .NET, decimal values were converted to doubles in DataWindow expressions. DataWindow .NET 2.0 adds support for decimal values in DataWindow expressions and new DataWindow expression functions to support decimal values. You can also use decimal values as retrieval arguments. The decimal datatype supports up to 28 digits.

The following arithmetic operators now return a decimal value if both operands have a datatype of decimal:

Operator

Meaning

Example

+

Addition

Subtotal + Tax

-

Subtraction

Price - Discount

*

Multiplication

Quantity*Price

/

Division

Discount/Price

If either operand is not a decimal, the returned value is converted to a double datatype. The exponentiation operator (^) continues to return a double.

Relational operators that operate on numeric values, including =, >, <, <>, >=, and <=, can take decimal operands. The precision of the decimal operand is maintained in comparisons.

The following functions return a decimal datatype if their arguments are decimals: Sum, CumulativeSum, Avg, Median, First, Last, Max, Min, Large, Small, Var, VarP, Mod, Mode, Abs, Case, If.

The following new functions return a decimal result instead of a double: CrosstabAvgDec, CrosstabMaxDec, CrosstabMinDec, and CrosstabSumDec.

The new Dec function converts a constant string to a decimal. You can also append the letter D in upper or lowercase to identify a number as a decimal constant in a DataWindow expression. For example, 2.0d and 123.456789012345678901D are treated as decimals.

Decimal and Decimal array have been added to the list of types in the Specify Retrieval Arguments dialog box.

For descriptions of the new functions, see the DataWindow Object Reference.