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

Math Functions

Uploaded by

shasumith12
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Math Functions

Uploaded by

shasumith12
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

MATH FUNCTIONS

FUNCTION DESCRIPTION RETURN DATA TYPE SYNTAX


min(a,b) Returns the smaller number between a and Int/long/float/double Math.min(a,b);
b.
max(a,b) Returns the greater number between a and Int/long/float/double Math.max(a,b);
b.
sqrt(a) Returns the square root of a positive double Math.sqrt(a);
number.
cbrt(a) Returns the cube root of a positive double Math.cbrt(a);
number.
pow(a,b) Returns the value of ab double Math.pow(a,b);
abs(a) Returns the absolute value (magnitude) of Int/long/float/double Math.abs(a);
a number.
round(a) Returns the rounded value up to the double Math.round(a);
nearest integer.
floor(a) Returns the rounded value down to the double Math.floor(a);
nearest integer.
Ceil(a) Returns the whole number greater than or double Math.ceil(a);
equal to the number.
Random() Returns a random number between 1 and double Math.random();
0.

PROGRAM-

public class math_functions

public static void main()

int a=3,b=4;

System.out.println(Math.min(a,b));

public static void main1()

double b=2.34;

int a=5;

System.out.println(Math.max(a,b));

public static void main2()


MATH FUNCTIONS
{

double a=-2.45;

System.out.println(Math.abs(a));

public static void main3()

double a=3.51;

System.out.println(Math.round(a));

public static void main4()

double a=7.34;

System.out.println(Math.ceil(a));

public static void main5()

double a=7.34;

System.out.println(Math.floor(a));

public static void main6()

System.out.println(Math.random());

You might also like