bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths

Loading lesson path

Learn/Java/Java Reference
Java•Java Reference

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

ParameterDescription
numberRequired. 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+

Previous

Java Math scalb() Method

Next

Java Math sin() Method