Integer Sign Determination

Integer Sign Determination

Identify whether a given integer is positive, negative, or zero and return a respective string: "positive", "negative" or "zero".

example

Input: Integer (number).

Output: String (string).

Examples:

assert.strictEqual(determineSign(5), "positive");
assert.strictEqual(determineSign(0), "zero");
assert.strictEqual(determineSign(-10), "negative");
assert.strictEqual(determineSign(1), "positive");

How it’s used: understanding the sign of a number can be useful in financial software, scientific simulations, and many algorithms to determine subsequent logic.

Precondition:

  • num ∈ Z.