@tempots/std

sign() function

sign returns -1 if value is a negative number, 1 otherwise.

Signature:

sign: extends number>(value: T) => number

Parameters

Parameter

Type

Description

value

T

The number to check.

Returns: number

-1 if the number is negative, 1 otherwise.

Example

sign(-5) // returns -1
sign(5) // returns 1