The SGN function in ProBuilder language is used to determine the sign of a given numerical value. It returns -1, 0, or 1 based on whether the number is negative, zero, or positive, respectively. This function is useful in various programming scenarios where the sign of a number affects the flow or outcome of the code.
SGN(a)
Where a is a numerical expression for which the sign will be determined.
variable1 = -15
variable2 = 0
variable3 = 10
sign1 = SGN(variable1) // Returns -1
sign2 = SGN(variable2) // Returns 0
sign3 = SGN(variable3) // Returns 1
In this example, three variables are defined with different numerical values. The SGN function is used to determine the sign of each variable. The results are stored in sign1, sign2, and sign3 respectively, demonstrating how the function categorizes the numbers as negative, zero, or positive.
This function is straightforward but essential for handling numerical data effectively in the ProBuilder programming environment.