Documentation for routine sign

Documentation for routine sign, assembled from the following types:

class Cool

From Cool

(Cool) method sign

Defined as:

method sign()

Coerces the invocant to Numeric and returns its sign, that is, 0 if the number is 0, 1 for positive and -1 for negative values.

say 6.sign;             # OUTPUT: «1␤» 
say (-6).sign;          # OUTPUT: «-1␤» 
say "0".sign;           # OUTPUT: «0␤» 

role Real

From Real

(Real) method sign

method sign(Real:D:)

Returns -1 if the number is negative, 0 if it is zero and 1 otherwise.