## Description :

This java tutorial shows how to use the round(float a) method of Math class under java.lang package. This method returns the absolute value of the double method argument.

## Method Syntax :

public static int round(float a)

## Parameter Input :

DataType Parameter Description
double a the value which we want to determine the absolute representation

## Method Returns :

The abs(double a) method simply returns the absolute value of the argument.

## Compatibility Version :

Requires Java 1.0.2 and up

N/A

## Discussion :

The abs(double a) method is static thus we should invoke it statically for example Math.abs(double a). This method simply takes the absolute value of the method argument in consideration with the following special consideration:

• If the argument is positive zero or negative zero, the result is positive zero.
• If the argument is infinite, the result is positive infinity.
• If the argument is NaN, the result is NaN.

This method is very necessary specially in dealing with mathematical expression which requires to get the absolute value. Taking the absolute value means we are taking out the sign that precedes the numerical value.

## Java Code Example :

This java example source code demonstrates the use of abs(double a) method of Math class. Basically we just get the absolute value of a double variable and then print the results.

```package com.javatutorialhq.java.examples;

import static java.lang.System.*;

/*
* This example source code demonstrates the use of
* abs(double a) method of Math class
* Get the absolute value of a double
*/

public class MathAbsDouble {

public static void main(String[] args) {
// declare the double value to get the absolute value
double d = -100;
// get the absolute value
double absolutValue = Math.abs(d);
out.println(d+" absolute value is "+absolutValue);

}

}```

## Sample Output :

Running the abs(double a) method example source code of Math class will give you the following output

`-100.0 absolute value is 100.0`

`N/A`

• N/A