In role Real§

See primary documentation in context for method sign

method sign(Real:D:)

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

In Cool§

See primary documentation in context for method sign

method sign()

Coerces the invocant to Real 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␤»

In Complex§

See primary documentation in context for routine sign

method sign(Complex:D: --> Complex:D)
multi  sign(Complex:D $z --> Complex:D)

Returns 0i if the absolute value of the complex number is 0. Otherwise returns the complex number divided by its absolute value (the unit complex number in the same direction as $z).

Available as of 6.e language version (early implementation exists in Rakudo compiler 2023.02+).