Conversions
HCL Detect Expression Language supports explicit conversions via casts using a function call syntax. The name of the function is the name of the type we want to cast to.
Examples:
- Casting an
Int32to aString:String(14)yields"14" - Casting a
Stringto aDouble:Double("4.5")yields4.5 - Casting a
Stringto aDouble:Double("nan")yieldsNaN(not a number)
HCL Detect Expression Language
supports implicit conversions (aka coercions) as well. When two integers of
different types are involved in an operation, the one that has the smaller number of
bits is coerced into the wider type. When an integer is involved in an operation
with a Double it is coerced into a Double. Also
note that, in such operations, Int64 values that cannot be
represented exactly will be rounded to the closest Double
value.
Examples:
- Coercion with integers of different bit-lengths:
count/2has typeInt64, assumingcountis of typeInt64(this has the same semantics as the expressioncount / Int64(2)) - Coercion involving an
Int32and aDouble:timestamp / 1000has typeDouble, assumingtimestampis of typeDouble(this has the same semantics as the expressiontimestamp / Double(1000))