These functions let you do mathematical calculations.
Performance tip for UNIX, Windows NT, and OS/2: You can optimize the performance of mathematical functions with the DTW_OPTIMIZE_MATH configuration value by setting it to YES in the Net.Data initialization file or the macro file.
See the configuration variables section of the Net.Data Administration and Programming Guide to learn how to configure this variable.
NLS considerations for math functions: Net.Data displays decimal points in numerical values based on regional settings specified at the Web server under which Net.Data is running. For example, if the decimal point is specified as a comma (,) at the Web server, Net.Data uses the comma to format decimal data. Net.Data uses the following settings to determine which character is used to specify a decimal point:
The following functions are available for mathematical calculations:
| AIX | HP-UX | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
| X | X | X | X | X | X | X | X |
Purpose
Adds the values of two parameters.
Format
@DTW_ADD(number1, number2, precision, result)
@DTW_ADD(number1, number2, result)
@DTW_rADD(number1, number2, precision)
@DTW_rADD(number1, number2)
Values
| Data Type | Parameter | Use | Description |
|---|---|---|---|
| float | number1 | IN | A variable or literal string representing a number. |
| float | number2 | IN | A variable or literal string representing a number. |
| integer | precision | IN | A variable or literal string representing a positive whole number that specifies the precision of the result. The default is 9. |
| float | result | OUT | A variable that contains the sum of number1 and number2. |
Examples
Example 1:
@DTW_ADD(NUM1, NUM2, "2", result)
Example 2:
@DTW_rADD("12", NUM2, "5")
| AIX | HP-UX | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
| X | X | X | X | X | X | X | X |
Purpose
Divides the value of the first parameter by the value of the second parameter.
Format
@DTW_DIVIDE(number1, number2, precision, result)
@DTW_DIVIDE(number1, number2, result)
@DTW_rDIVIDE(number1, number2, precision)
@DTW_rDIVIDE(number1, number2)
Values
Table 41. DTW_DIVIDE Parameters
| Data Type | Parameter | Use | Description |
|---|---|---|---|
| float | number1 | IN | A variable or literal string representing a number. |
| float | number2 | IN | A variable or literal string representing a number. |
| integer | precision | IN | A variable or literal string representing a positive whole number that specifies the precision of the result. The default is 9. |
| float | result | OUT | A variable that contains the result of number1 divided by number2. |
Examples
Example 1:
@DTW_DIVIDE("8.0", NUM2, result)
Example 2:
@DTW_rDIVIDE("1", NUM2, "5")
Example 3:
@DTW_rDIVIDE(NUM1, "2", "5")
| AIX | HP-UX | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
| X | X | X | X | X | X | X | X |
Purpose
Divides the first parameter by the second parameter and returns the remainder. The sign of the remainder, if nonzero, is the same as that of the first parameter.
Format
@DTW_DIVREM(number1, number2, precision, result)
@DTW_DIVREM(number1, number2, result)
@DTW_rDIVREM(number1, number2, precision)
@DTW_rDIVREM(number1, number2)
Values
Table 42. DTW_DIVREM Parameters
| Data Type | Parameter | Use | Description |
|---|---|---|---|
| float | number1 | IN | A variable or literal string representing a number. |
| float | number2 | IN | A variable or literal string representing a number. |
| integer | precision | IN | A variable or literal string representing a positive whole number that specifies the precision of the result. The default is 9. |
| float | result | OUT | A variable that contains the remainder of number1 divided by number2. |
Examples
Example 1:
@DTW_DIVREM(NUM1, NUM2, result)
Example 2:
@DTW_rDIVREM("10", NUM2)
Example 3:
@DTW_rDIVREM("3.6", "1.3")
Example 4:
@DTW_rDIVREM("-10", "3")
| AIX | HP-UX | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
| X | X | X | X | X | X | X | X |
Purpose
Customizes the formatting for a number. If only the number parameter is specified, the result is formatted just as if @DTW_rADD(number,"0") was performed. If any other options are specified then the number is formatted according to the following rules:
Format
@DTW_FORMAT(number, before, after, expp, expt, precision, result)
@DTW_FORMAT(number, before, after, expp, expt, result)
@DTW_FORMAT(number, before, after, expp, result)
@DTW_FORMAT(number, before, after, result)
@DTW_FORMAT(number, before, result)
@DTW_FORMAT(number, result)
@DTW_rFORMAT(number, before, after, expp, expt, precision)
@DTW_rFORMAT(number, before, after, expp, expt)
@DTW_rFORMAT(number, before, after, expp)
@DTW_rFORMAT(number, before, after)
@DTW_rFORMAT(number, before)
@DTW_rFORMAT(number)
Values
Table 43. DTW_FORMAT Parameters
| Data Type | Parameter | Use | Description |
|---|---|---|---|
| float | number | IN | A variable or literal string representing a number. |
| integer | before | IN | A variable or literal string representing a positive whole number. This is an optional parameter. You must enter a null string ("") to have additional parameters. |
| integer | after | IN | A variable or literal string representing a positive whole number. This is an optional parameter. You must enter a null string ("") to specify additional parameters. |
| integer | expp | IN | A variable or literal string representing a positive whole number. You must specify a null string ("") to specify additional parameters. |
| integer | expt | IN | A variable or literal string representing a positive whole number. You must enter a null string ("") to specify additional parameters. |
| integer | precision | IN | A variable or literal string representing a positive whole number that specifies the precision of the result. The default is 9. |
| float | result | OUT | A variable that contains the number with the specified rounding and formatting. |
Examples
Example 1:
@DTW_FORMAT(NUM, BEFORE, result)
Example 2:
@DTW_FORMAT("1.73", "4", "0", result)
Example 3:
@DTW_FORMAT("1.73", "4", "3", result)
Example 4:
@DTW_FORMAT(" - 12.73", "", "4", result)
Example 5:
@DTW_FORMAT("12345.73", "", "", "2", "2", result)
Example 6:
@DTW_FORMAT("1.234573", "", "3", "", "0", result)
Example 7:
@DTW_rFORMAT(" - 12.73")
Example 8:
@DTW_rFORMAT("0.000")
Example 9:
@DTW_rFORMAT("12345.73", "", "", "3", "6")
Example 10:
@DTW_rFORMAT("1234567e5", "", "3", "0")
Example 11:
@DTW_rFORMAT("12345.73", "", "3", "", "0")
| AIX | HP-UX | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
| X | X | X | X | X | X | X | X |
Purpose
Divides the first parameter by the second parameter and returns the integer part of the result.
Format
@DTW_INTDIV(number1, number2, precision, result)
@DTW_INTDIV(number1, number2, result)
@DTW_rINTDIV(number1, number2, precision)
@DTW_rINTDIV(number1, number2)
Values
Table 44. DTW_INTDIV Parameters
| Data Type | Parameter | Use | Description |
|---|---|---|---|
| float | number1 | IN | A variable or literal string representing a number. |
| float | number2 | IN | A variable or literal string representing a number. |
| integer | precision | IN | A variable or literal string representing a positive whole number that specifies the precision of the result. The default is 9. |
| float | result | OUT | A variable that contains integer part of number1 divided by number2. |
Examples
Example 1:
@DTW_INTDIV(NUM1, NUM2, result)
Example 2:
@DTW_rINTDIV("2", NUM2)
| AIX | HP-UX | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
| X | X | X | X | X | X | X | X |
Purpose
Multiplies two parameters and returns the result.
Format
@DTW_MULTIPLY(number1, number2, precision, result)
@DTW_MULTIPLY(number1, number2, result)
@DTW_rMULTIPLY(number1, number2, precision)
@DTW_rMULTIPLY(number1, number2)
Values
Table 45. DTW_MULTIPLY Parameters
| Data Type | Parameter | Use | Description |
|---|---|---|---|
| float | number1 | IN | A variable or literal string representing a number. |
| float | number2 | IN | A variable or literal string representing a number. |
| integer | precision | IN | A variable or literal string representing a positive whole number that specifies the precision of the result. The default is 9. |
| float | result | OUT | A variable that contains the product of number1 and number2. |
Examples
Example 1:
@DTW_MULTIPLY(NUM1, NUM2, result)
Example 2:
@DTW_rMULTIPLY("0.9", NUM2)
| AIX | HP-UX | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
| X | X | X | X | X | X | X | X |
Purpose
Raises the first parameter to the power of the second parameter and returns the result.
Format
@DTW_POWER(number1, number2, precision, result)
@DTW_POWER(number1, number2, result)
@DTW_rPOWER(number1, number2, precision)
@DTW_rPOWER(number1, number2)
Values
Table 46. DTW_POWER Parameters
| Data Type | Parameter | Use | Description |
|---|---|---|---|
| float | number1 | IN | A variable or literal string representing a number. |
| float | number2 | IN | A variable or literal string representing a number. |
| integer | precision | IN | A variable or literal string representing a positive whole number that specifies the precision of the result. The default is 9. |
| float | result | OUT | A variable that contains the result of number1 raised to the power of number2. |
Examples
Example 1:
@DTW_POWER(NUM1, NUM2, result)
Example 2:
@DTW_rPOWER("1.7", NUM2, precision)
| AIX | HP-UX | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
| X | X | X | X | X | X | X | X |
Purpose
Subtracts the value of the second parameter from the value of the first parameter and returns the result.
Format
@DTW_SUBTRACT(number1, number2, precision, result)
@DTW_SUBTRACT(number1, number2, result)
@DTW_rSUBTRACT(number1, number2, precision)
@DTW_rSUBTRACT(number1, number2)
Values
Table 47. DTW_SUBTRACT Parameters
| Data Type | Parameter | Use | Description |
|---|---|---|---|
| float | number1 | IN | A variable or literal string representing a number. |
| float | number2 | IN | A variable or literal string representing a number. |
| integer | precision | IN | A variable or literal string representing a positive whole number that specifies the precision of the result. The default is 9. |
| float | result | OUT | A variable that contains the difference of number1 and number2. |
Examples
Example 1:
@DTW_SUBTRACT(NUM1, NUM2, comp) %IF(comp > "0") <P>$(NUM1) is larger than $(NUM2). %ENDIF
This example shows a way to compare numeric values, which are strings in Net.Data.
Example 2:
@DTW_SUBTRACT(NUM1, NUM2, result)
Example 3:
@DTW_rSUBTRACT("1.3", NUM2)