sign of ()
Sign of ()
The sign of () block is a reporter block in the Extra Mathematics extension that reports the sign function of the inputted number, which returns -1 for negative numbers, 0 for zero, and 1 for positive numbers. The default value is 0.
Workaround
This block can be worked around by using the following:
((([abs v] of (number::grey)) / (number::grey)) + (0))
The + (0) is used to get 0 when 0 is the number, rather than NaN.
It can also be worked around using if statements to detect the sign:
define sign of (num) if <(num) < [0]> then { return [-1]::custom cap } else if <((num) * (1)) = [0]> then { return [0]::custom cap }::control return [1]::custom cap
The * (1) is for reporting 0 with string inputs.