About SRL coercion

Coercion which is also referred to as "casting" or "type casting" or "type conversion" is a process of changing one data type to a different one. PolyAnalyst may automatically change the type of a value when evaluating a SRL expression.

For example, PolyAnalyst may change the type of a value from a number to a string, or from a date to a number.

For example, considering adding 5.5 to 1 to get 6.5.

1) In the expression 5.5 + 1, the integer 1 is first converted to the numeric value 1.0 (so the expression becomes 5.5 + 1.0).
2) Now we sum two values of the same type and get 6.5

The integer value 1 went through a type conversion in order to satisfy the requirement that each operand (each value) of the addition operator has the same type. Type conversion also takes place when working with some of the other data types.

In other words, if we were to take the expression 5.5 + 1 and attempt to convert the numeric value 5.5 to just the integer 5, we would be ignoring the 0.5 component, and therefore we would be experiencing a loss of data.

Boolean values can be added together due to type coercion as the values are coerced into integers. TRUE and YES both represent the integer 1. FALSE and NO both represent the integer 0. You are able to create expressions like TRUE + 1, or TRUE - 4, or NO / FALSE * TRUE, because of this coercion.

The + operator can be used for concatenation of strings, which means to take the characters of one string and append those characters to the end of another string. The + operator can also be used between a number and a string, in which case the number is first converted to a string, then concatenated with the other string. This happens implicitly via coercion.