Pure Programmer
Blue Matrix


Cluster Map

Project: Sign Function

Write a function that takes an integer and computes the sign of the value. The function should return -1 if the argument is negative, +1 if it is positive and 0 if it is zero.

Output
$ javac -Xlint SignFunction.java $ java -ea SignFunction sign(5) : 1 sign(-5) : -1 sign(0) : 0

Solution