Math.sqrt, Math.abs, math.sin, math.cos | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

Math.sqrt, Math.abs, math.sin, math.cos

Can anybody tell me what does these classes do?

28th Nov 2018, 5:15 AM
Lycanthrope
Lycanthrope - avatar
4 Answers
+ 15
●Math.sqrt(a) returns square root of value a ●Math.abs(a) return absolute value(ie distance from origion , which will be always positive , it works like modulus function) of value a ●Math.sin(a) return sine of angle a ●Math.cos(a) returns cosine of angle a //these are methods , class name generally starts with Capital letter[tip to identify class name]
28th Nov 2018, 5:22 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 10
● Math.sqrt(4.0) //2.0 ● Math.abs(-2.0) //2.0 ● Math.sin(Math.toRadians(30)) //0.5 ● Math.cos(0) //1.0 //as by default we give value of angle in radian in trigonometric ratios
28th Nov 2018, 9:30 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 3
Thanks buddy👍
28th Nov 2018, 9:50 AM
Lycanthrope
Lycanthrope - avatar
+ 2
Can you give me some example? Plz
28th Nov 2018, 7:32 AM
Lycanthrope
Lycanthrope - avatar