Curriculum
Course: Java Basic
Login

Curriculum

Java Basic

Java Home

0/1

Java Introduction

0/1

Java Get Started

0/1

Java Syntax

0/1

Java Comments

0/1

Java Type Casting

0/1

Java Operators

0/1

Java Booleans

0/1

Java Switch

0/1

Java Break / Continue

0/1

Java Errors and Exception

0/1
Text lesson

signum()

Example

“Provide the sign of various numbers.”

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 determines the sign of a number, with 1 indicating positivity, -1 indicating negativity, and 0 representing zero.

Syntax

public static double signum(double number)

 

public static float signum(float number)

Parameter Values

Parameter

Description

number

“Necessary. A number for which the sign needs to be determined.”

Technical Details

Returns:

A double or float value indicating the sign of a number, returning 1 for positive numbers, -1 for negative numbers, and 0 for zero.

Java Version:

1.5+