Grokking Modern System Design Interview for Engineers & Managers
Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.
The static signum
function of the Long
class is used to get the signum
function of the specified long value.
The signum denotes the sign of a real number.
-1
.1
.0
.The following is the function prototype:
public static int signum(long i)
This method takes a long
value as an argument.
This method returns:
1
if the argument is greater than zero.
-1
if the argument is less than zero.
0
if the argument is equal to zero.
The example below uses the signum
function.
class LongSignumExample {public static void main(String[] args) {System.out.println("Signum for -10l is " + Long.signum(-10l));System.out.println("Signum for 10l is " + Long.signum(10l));System.out.println("Signum for 0 is " + Long.signum(0));}}
In the code above:
In line 3, we called Long.signum(-10l)
. This will return -1
because the argument(-10l
) is less than zero.
In line 4, we called Long.signum(10l)
. This will return -1
because argument(10l
) is greater than zero.
In line 5, we called Long.signum(0)
. This will return 0
because the argument is equal to zero.
RELATED TAGS
CONTRIBUTOR
Grokking Modern System Design Interview for Engineers & Managers
Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.