Math.cos()

Math.cos() returns the trigonometric cos value of an angle in radian.
Syntax
Math.cos(angle_in_radian)
Note that all input numbers are in Radians.

Here are some examples.
System.out.println(Math.cos(Math.PI));	//-1
System.out.println(Math.cos(Math.PI/2));//6.123233995736766E-17
System.out.println(Math.cos(2)); 	//-0.4161468365471424
System.out.println(Math.cos(1.22));	//0.34364574631604705
System.out.println(Math.cos(-1.22)); 	//0.34364574631604705
System.out.println(Math.cos(0)); 	// 1.0
We can use toRadians to convert degree value to radian.
Math.round() to rounds a floot or double data type to nearest integer value
System.out.println(Math.round((Math.cos(Math.toRadians(180)))));//-1
System.out.println((Math.cos(Math.toRadians(180))));//-1.0
System.out.println(Math.cos(Math.toRadians(90)));//6.123233995736766E-17
System.out.println(Math.cos(Math.PI)); 	//-1.0
System.out.println(Math.cos(Math.PI/2));//6.123233995736766E-17


All Math functions

Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com



    Post your comments , suggestion , error , requirements etc here




    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer