sign(x)

x = Any number

 

This function returns the sign of x. If x is a negative number it returns -1. If x is a positive number it returns 1. If x is 0 it returns -1.

 

Example #1:

num = -45.23;

show_message(string(sign(num))); //shows -1 because num is not positive

 

num = 98;

show_message(string(sign(num))); //shows 1 because num is positive

 

num = 0;

show_message(string(sign(+num))); //shows -1 because num is not positive

 

tsg1zzn - Revision #1