signum

Summary

Returns a value indicating the sign for a number.

Signatures

Click on a signature to select it and view its documentation.

Usage

public static int signum(int x)

Returns

0 if the argument is 0, 1 if the argument is greater than 0, and -1 if the argument is less than 0.

Parameters

x

The number to extract the sign from.

Description

Returns a value indicating the sign for a number. 0 if the argument is 0, 1 if the argument is positive (greater than 0), and -1 if the argument is negative (less than 0).

Examples

Basic Usage
1
2
3
4
5
import System;
 
Console.log(Math.signum(-100)); // -1, negative number
Console.log(Math.signum(0));    // 0, zero value
Console.log(Math.signum(50));   // 1, positive number

Share

HTML | BBCode | Direct Link