0% found this document useful (0 votes)
150 views1 page

Java Math Functions Overview

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

Java Math Functions Overview

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

Java Math Functions Table (With Return Types)

Function Syntax Return Data Type Description Example Output

Absolute Value [Link](x) int / double Returns absolute (positive) value of x. [Link](-10) 10

Power [Link](x, y) double Returns x^y (x raised to power y). [Link](2, 3) 8.0

Square Root [Link](x) double Returns square root of x. [Link](36) 6.0

Cube Root [Link](x) double Returns cube root of x. [Link](27) 3.0

Maximum [Link](a, b) int / double Returns larger of two numbers. [Link](5, 9) 9

Minimum [Link](a, b) int / double Returns smaller of two numbers. [Link](5, 9) 5

Round [Link](x) long / int Rounds x to nearest whole number. [Link](4.7) 5

Ceiling [Link](x) double Rounds x upward to nearest integer. [Link](4.1) 5.0

Floor [Link](x) double Rounds x downward to nearest integer. [Link](4.9) 4.0

Random [Link]() double Returns random number between 0.0 and 1.0. [Link]() 0.0 to 1.0

PI Constant [Link] double Returns value of π (3.14159…) [Link] 3.14159…

Exponential [Link](x) double Returns e^x (e ≈ 2.718) [Link](1) 2.71828…

Log (Base e) [Link](x) double Returns natural log of x. [Link](10) 2.3025…

Log (Base 10) Math.log10(x) double Returns log base 10 of x. Math.log10(100) 2.0

Sine [Link](angle) double Returns sine of angle (in radians). [Link]([Link]/2) 1.0

Cosine [Link](angle) double Returns cosine of angle (in radians). [Link](0) 1.0

Tangent [Link](angle) double Returns tangent of angle (in radians). [Link]([Link]/4) 1.0

Convert to Radians [Link](deg) double Converts degrees → radians. [Link](180) 3.14159…

Convert to Degrees [Link](rad) double Converts radians → degrees. [Link]([Link]) 180.0

You might also like