signum
fn signum(int x) -> intfn signum(float x) -> float Import
Source: use num::{signum}; src/num.hy Returns -1, 0 or 1 by the sign of x.
fn signum(int x) -> int#
Parameters#
| Name | Type |
|---|---|
x | int |
Returns#
int
fn signum(float x) -> float#
Returns -1.0, 0.0 or 1.0 by the sign of x; a zero keeps its sign.
Parameters#
| Name | Type |
|---|---|
x | float |
Returns#
float
Examples#
use num::{signum};
use tests::assert;
assert!(signum(-8) == -1);
assert!(signum(0) == 0);
See also#
abs: Returns the absolute value ofx.min: Returns the smaller ofaandb(awhen they are equal).max: Returns the larger ofaandb(awhen they are equal).round: Roundsxto the nearest whole number; halves round away from zero.clamp: Returnsxlimited to the rangelo..=hi.gcd: Returns the greatest common divisor ofaandb, which should be non-negative.lcm: Returns the least common multiple ofaandb, which should be non-negative;0when either is0.trunc: Removes the fractional part ofx, rounding toward zero.