0% found this document useful (0 votes)
5 views

Java Math Library Functions

The document outlines various methods available in the Java Math library, including functions for calculating absolute values, logarithms, powers, and square roots. Each method is described with its return type and functionality, such as returning the maximum or minimum of two values. Additionally, it includes methods for generating random numbers and rounding values.

Uploaded by

bbhar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Java Math Library Functions

The document outlines various methods available in the Java Math library, including functions for calculating absolute values, logarithms, powers, and square roots. Each method is described with its return type and functionality, such as returning the maximum or minimum of two values. Additionally, it includes methods for generating random numbers and rounding values.

Uploaded by

bbhar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Java Math Library Func ons

Modifier and Type Method and Descrip on


static double abs(double a)
Returns the absolute value of a double value.
static float abs(float a)
Returns the absolute value of a float value.
static int abs(int a)
Returns the absolute value of an int value.
static long abs(long a)
Returns the absolute value of a long value.
static double cbrt(double a)
Returns the cube root of a double value.
static double ceil(double a)
Returns the smallest (closest to nega ve
infinity) double value that is greater than or equal to the
argument and is equal to a mathema cal integer.
static double floor(double a)
Returns the largest (closest to posi ve
infinity) double value that is less than or equal to the
argument and is equal to a mathema cal integer.
static double log(double a)
Returns the natural logarithm (base e) of a double value.
static double log10(double a)
Returns the base 10 logarithm of a double value.
static double max(double a, double b)
Returns the greater of two double values.
static float max(float a, float b)
Returns the greater of two float values.
static int max(int a, int b)
Returns the greater of two int values.
static long max(long a, long b)
Returns the greater of two long values.
Modifier and Type Method and Descrip on
static double min(double a, double b)
Returns the smaller of two double values.
static float min(float a, float b)
Returns the smaller of two float values.
static int min(int a, int b)
Returns the smaller of two int values.
static long min(long a, long b)
Returns the smaller of two long values.
static double pow(double a, double b)
Returns the value of the first argument raised to the
power of the second argument.
static double random()
Returns a double value with a posi ve sign, greater than
or equal to 0.0 and less than 1.0.
static double rint(double a)
Returns the double value that is closest in value to the
argument and is equal to a mathema cal integer.
static long round(double a)
Returns the closest long to the argument, with es
rounding to posi ve infinity.
static int round(float a)
Returns the closest int to the argument, with es
rounding to posi ve infinity.
static double sqrt(double a)
Returns the correctly rounded posi ve square root of
a double value.

You might also like