DecimalOps class | QSYS API Reference Guide
Estimated reading time: 12 minutes
Provide fixed length decimal storage and operations.
Namespace: ASNA.QSys.Runtime
Assembly: ASNA.QSys.Runtime.dll
Inheritance: Object
Methods
| Signature |
Description |
| ConvertToString(Decimal, Int32, Int32, Boolean) |
Formats a numeric value by fixing the number of digits and decimals and converts to string. |
| DecimalToMemUnits(Decimal, Int32, Int32) |
Convert a decimal of the given size to its memory layout representation. |
| DecimalToMemUnitsSigned(Decimal, Int32, Int32) |
Convert a decimal of the given size to its memory layout representation, encoding the sign in each of the digits. |
| Divide(Decimal, Decimal, Decimal&, Int32, Boolean, Boolean) |
Executes a DIVIDE operation. |
| FixDecimal(Decimal, Int32, Int32, Boolean) |
Formats a numeric value by fixing the number of digits and decimals. |
| FixDecimalH(Decimal, Int32, Int32, Boolean) |
Formats a numeric value by fixing the number of digits and decimals using half adjust. |
| FixI4(Int32, Int32, Int32, Boolean) |
Formats a numeric value by fixing the number of digits and decimals. |
| GetIndicators(Decimal, Boolean&, Boolean&, Boolean&) |
Gets the HI-LO-EQ indicator conditions. |
| MakeHiVal(Int32, Int32) |
Makes a decimal HI-VALUE. |
| MapFromPacked(Decimal, Int32) |
Converts Packed format number to a string. |
| MapToPacked(String, Int32) |
Converts number in a string to a Packed format numeric value. |
| MemUnitsToDecimal(String, Int32, Int32) |
Converts a string representing a the number as a memory digits to the numeric value. |
| RoundUp(Decimal, Int32, Int32, Boolean) |
Rounds-up a decimal value. |
| RoundUpDecimals(Decimal, Int32) |
Round-up a decimal value. |
| Trim(Decimal, Int32, Int32, vxAdjust, Boolean) |
Trims a decimal value. |
| Truncate(Decimal, Int32, Int32, Boolean) |
Truncates a decimal value. |
| TruncateDecimals(Decimal, Int32) |
Truncates a decimal value. |
Formats a numeric value by fixing the number of digits and decimals and converts to string.
string ConvertToString(decimal number, int integrals, int decimals, bool zeroPad)
Parameters
| Type |
Parameter name |
Description |
| Decimal |
number |
Input value. |
| Int32 |
integrals |
Number of digits. |
| Int32 |
decimals |
Number of decimals. |
| Boolean |
zeroPad |
True if padding with zeros is to be performed; False otherwise. |
Returns
| Type |
Description |
| String |
Fixed-length numeric result as string. |
Convert a decimal of the given size to its memory layout representation.
string DecimalToMemUnits(decimal number, int integrals, int decimals)
Parameters
| Type |
Parameter name |
Description |
| Decimal |
number |
Input number. |
| Int32 |
integrals |
Number of digits. |
| Int32 |
decimals |
Number of decimal positions/ |
Returns
| Type |
Description |
| String |
The string memory representation. |
Convert a decimal of the given size to its memory layout representation, encoding the sign in each of the digits.
string DecimalToMemUnitsSigned(decimal number, int integrals, int decimals)
Parameters
| Type |
Parameter name |
Description |
| Decimal |
number |
Input number. |
| Int32 |
integrals |
Number of digits. |
| Int32 |
decimals |
Number of decimal positions/ |
Returns
| Type |
Description |
| String |
The string memory representation. |
Executes a DIVIDE operation.
decimal Divide(decimal f1, decimal f2, Decimal& globalRemainder, int resultDecimals, bool isRoundUp, bool checkOverflow)
Parameters
| Type |
Parameter name |
Description |
| Decimal |
f1 |
Input factor one. |
| Decimal |
f2 |
Input factor two. |
| Decimal& |
globalRemainder |
Output reminder. |
| Int32 |
resultDecimals |
Input result decimals. |
| Boolean |
isRoundUp |
True if rounding is to be performed in the result; False otherwise. |
| Boolean |
checkOverflow |
True if overflow condition is to be checked; False otherwise. |
Returns
| Type |
Description |
| Decimal |
The result of the decimal division with the requested resulting decimal positions, truncated or rounded. |
Formats a numeric value by fixing the number of digits and decimals.
decimal FixDecimal(decimal number, int digits, int decimals, bool checkOverflow)
Parameters
| Type |
Parameter name |
Description |
| Decimal |
number |
Input value. |
| Int32 |
digits |
Number of digits. |
| Int32 |
decimals |
Number of decimals. |
| Boolean |
checkOverflow |
True if overflow is to be checked; False otherwise. |
Returns
| Type |
Description |
| Decimal |
Fixed-length numeric result. |
Formats a numeric value by fixing the number of digits and decimals using half adjust.
decimal FixDecimalH(decimal number, int digits, int decimals, bool checkOverflow)
Parameters
| Type |
Parameter name |
Description |
| Decimal |
number |
Input value. |
| Int32 |
digits |
Number of digits. |
| Int32 |
decimals |
Number of decimals. |
| Boolean |
checkOverflow |
True if overflow is to be checked; False otherwise. |
Returns
| Type |
Description |
| Decimal |
Fixed-length numeric result. |
Formats a numeric value by fixing the number of digits and decimals.
decimal FixI4(int digits, int decimals, int number, bool checkOverflow)
Parameters
| Type |
Parameter name |
Description |
| Int32 |
digits |
Number of digits. |
| Int32 |
decimals |
Number of decimals. |
| Int32 |
number |
Input value. |
| Boolean |
checkOverflow |
True if overflow is to be checked; False otherwise. |
Returns
| Type |
Description |
| Decimal |
Fixed-length numeric result. |
Gets the HI-LO-EQ indicator conditions.
void GetIndicators(decimal number, Boolean& HiIndicator, Boolean& LoIndicator, Boolean& EqIndicator)
Parameters
| Type |
Parameter name |
Description |
| Decimal |
number |
Input number. |
| Boolean& |
HiIndicator |
Output HI indicator. |
| Boolean& |
LoIndicator |
Output LO indicator. |
| Boolean& |
EqIndicator |
Output EQ indicator. |
Makes a decimal HI-VALUE.
decimal MakeHiVal(int length, int decimals)
Parameters
| Type |
Parameter name |
Description |
| Int32 |
length |
Input Length. |
| Int32 |
decimals |
Input number of decimals. |
Returns
| Type |
Description |
| Decimal |
The highest decimal value that fits in the given length and decimal positions. |
Converts Packed format number to a string.
string MapFromPacked(decimal number, int digits)
Parameters
| Type |
Parameter name |
Description |
| Decimal |
number |
Input number. |
| Int32 |
digits |
Number of digits. |
Returns
| Type |
Description |
| String |
The packed number converted to a string. |
Converts number in a string to a Packed format numeric value.
decimal MapToPacked(string baseString, int decimalCount)
Parameters
| Type |
Parameter name |
Description |
| String |
baseString |
Input string. |
| Int32 |
decimalCount |
Number of decimals. |
Returns
| Type |
Description |
| Decimal |
The converted packed decimal. |
Converts a string representing a the number as a memory digits to the numeric value.
decimal MemUnitsToDecimal(string digits, int integrals, int decimals)
Parameters
| Type |
Parameter name |
Description |
| String |
digits |
Input string. |
| Int32 |
integrals |
Number of digits. |
| Int32 |
decimals |
Number of decimals. |
Returns
| Type |
Description |
| Decimal |
The fixed-decimal conversion. |
Rounds-up a decimal value.
decimal RoundUp(decimal newValue, int integralCount, int decimalCount, bool checkOverflow)
Parameters
| Type |
Parameter name |
Description |
| Decimal |
newValue |
Input value. |
| Int32 |
integralCount |
Integral count. |
| Int32 |
decimalCount |
Decimal count. |
| Boolean |
checkOverflow |
True if overflow condition is to be checked; False otherwise. |
Returns
| Type |
Description |
| Decimal |
The rounded-up result. |
Round-up a decimal value.
decimal RoundUpDecimals(decimal newValue, int decimalCount)
Parameters
| Type |
Parameter name |
Description |
| Decimal |
newValue |
Input value. |
| Int32 |
decimalCount |
Decimal count. |
Returns
| Type |
Description |
| Decimal |
The rounded-up result. |
Trims a decimal value.
decimal Trim(decimal newValue, int integralCount, int decimalCount, vxAdjust AdjustParm, bool checkOverflow)
Parameters
| Type |
Parameter name |
Description |
| Decimal |
newValue |
Input value. |
| Int32 |
integralCount |
Integral count. |
| Int32 |
decimalCount |
Decimal count. |
| vxAdjust |
AdjustParm |
How to half-adjust. |
| Boolean |
checkOverflow |
True if overflow condition is to be checked; False otherwise. |
Returns
| Type |
Description |
| Decimal |
The trimmed result. |
Truncates a decimal value.
decimal Truncate(decimal newValue, int integralCount, int decimalCount, bool checkOverflow)
Parameters
| Type |
Parameter name |
Description |
| Decimal |
newValue |
Input value. |
| Int32 |
integralCount |
Integral count. |
| Int32 |
decimalCount |
Decimal count. |
| Boolean |
checkOverflow |
True if overflow condition is to be checked; False otherwise. |
Returns
| Type |
Description |
| Decimal |
The truncated result. |
Truncates a decimal value.
decimal TruncateDecimals(decimal newValue, int decimalCount)
Parameters
| Type |
Parameter name |
Description |
| Decimal |
newValue |
Input value. |
| Int32 |
decimalCount |
Decimal count. |
Returns
| Type |
Description |
| Decimal |
The truncated result. |