Flash cards
Review the key moves
1/4
Core idea
What is the main idea behind Java Math signum() Method?
Lesson checks
Practice each idea before moving on
Short Mimo-style checks built from this lesson's code, terms, and sequence.
1Quick choice
Which statement best captures the main point of this lesson?
2Fill blank
Complete the missing token from the example code.
___.out.println(Math.signum(12));3Order
Put the learning moves in the order that makes the concept easiest to apply.
The signum() method returns the sign of a number.
Definition and Usage
Java Math signum() Method
❮ Math Methods
Example
System.out.println(Math.signum(12));
System.out.println(Math.signum(0.5));
System.out.println(Math.signum(0));
System.out.println(Math.signum(-0.25));
System.out.println(Math.signum(-6));Definition and Usage
The signum() method returns the sign of a number. A number's sign tells whether it is positive or negative. This method returns 1 for positive numbers, -1 for negative numbers and 0 for the number 0.
Syntax
public static double signum(double
number )public static float signum(float
number )Parameter Values
| Parameter | Description |
|---|---|
| number | Required. A number to find the sign of. |
Technical Details
| Returns: | A double or float value representing the sign of a number. Returns 1 for positive numbers, -1 for negative numbers and 0 for the number 0. |
|---|---|
| Java version: | 1.5+ |