0 / 0
Number functions

Number functions

Use the number functions to extract the mantissa from a decimal or floating point number. The Number category in the expression editor also contains the type casting functions, which you can use to cast numbers as double, float, or integer data types.

Square brackets indicate an argument is optional. The examples show the function as it appears in a Derivation field in the Transformer stage.

The type casting functions help you when you perform mathematical calculations using numeric fields. For example, if you have a calculation using an output column of type float derived from an input column of type integer in a Parallel Transformer stage the result is derived as an integer regardless of its float type. If you want a non-integral result for a calculation using integral operands, you can use the type casting functions to cast the integer operands into non-integral operands.

AsDouble
Treat the given number as a double.
  • Input: number
  • Output: number (double)
  • Examples. In the following expression, the input column mynumber contains an integer, but the function outputs a double. If mylink.mynumber contains the value 56, then the following two functions are equivalent, and return the value 1.29629629629629619E+01:
    AsDouble(56/4.32)
    AsDouble(mylink.mynumber/4.32)
    
AsFloat
Treat the given number as a float.
  • Input: number
  • Output: number (float)
  • Examples. In the following expression, the input column mynumber contains an integer, but the function outputs a float. If mylink.mynumber contains the value 56, then the following two functions are equivalent, and return the value 1.29629629629629619E+01:
    AsFloat(56/4.32)
    AsFloat(mylink.mynumber/4.32)
    
AsInteger
Treat the given number as an integer. But there a difference in behavior when a decimal is assigned to an integer versus a float or a double being assigned to an integer. If the conversion is from float or a double to an integer, it is a simple assignment to an integer. In case of decimal AsInteger(), function is invoked and rounds the output towards nearest value.
  • Input: number
  • Output: number (integer)
  • Examples. In the following expression, the input value 12.962963 has a type Double. Though the value is treated as type Double, the function outputs an integer. Hence it is a simple assignment to an integer and function returns the value 12:
    AsInteger(12.962963)
    
In the following expression, the calculations like (56/4.32) is treated as a type Decimal and AsInteger() function call invoked will round towards the nearest value and returns the value 13:
AsInteger(56/4.32)
Fix

Convert a numeric value to a floating-point number with a specified precision (number [,precision [,mode]])

  • Input: number (decimal), number (int32), number (int32)
  • Output: result (decimal)
  • Examples. If the column mylink.mylist contains number 2.01234, number 2 and number 1, then the following function returns the value 2.01:
    Fix("2.01234", 2, 1)
    Fix(mylink.mylist)
IsStrNum

Checks whether a string is a valid number. This function is present for compatibility but use is not encouraged.

  • Input: string (string)
  • Output: result (int32)
  • Examples. If the column mylink.mystring contains the string "1", then the following function returns the value 1:
    isStrNum(mylink.mystring)
IsVarNum

Checks whether variant is a valid number. This function is present for compatibility but use is not encouraged.

  • Input: variant (string)
  • Output: result (int32)
  • Examples. If the column mylink.myvariant contains the string "2", then the following function returns the value 1:
    IsVarNum(2)
    IsVarNum(mylink.myvariant)
    
    If the column mylink.myvariant contains the string "A", then the following function returns the value 0:
    IsVarNum(A)
    IsVarNum(mylink.myvariant)
    
MantissaFromDecimal
Returns the mantissa from the given decimal.
  • Input: number (decimal)
  • Output: result (dfloat)
  • Examples. If mylink.number contains the number 243.7675, then the following two functions are equivalent, and return the value 7675:
    MantissaFromDecimal(243.7675)
    MantissaFromDecimal(mylink.mynumber)
    
MantissaFromDFloat
Returns the mantissa from the given dfloat.
  • Input: number (dfloat)
  • Output: result (dfloat)
  • Examples. If mylink.number contains the number 1.234412000000000010E +4, then the following function returns the value 1:
    MantissaFromDFloat(mylink.mynumber)
    
VarCmp

Compares two variants. This function is present for compatibility but use is not encouraged.

  • Input: variant (string), variant (string), number (int32)
  • Output: result (int32)
  • Examples. If mylink.mylist contains string '11.123456', string '11.123456' and a number 3, then the following function returns the value 0:
    VarCmp('11.123456', '11.123456', 3)
    VarCmp(mylink.mylist)
    If mylink.mylist contains string '11.123456890', string '11.123456' and a number 3, then the following function returns the value 1:
    VarCmp('11.123456890', '11.123456', 3)
    VarCmp(mylink.mylist)
Generative AI search and answer
These answers are generated by a large language model in watsonx.ai based on content from the product documentation. Learn more