java - Why sin function in programming language returning strange sin value unlike calculators -


i familiar value of sin in calculator

enter image description here

when calculate in either java program or google.i getting strange value below

enter image description here

please let me know how works , if want calculator sin function in java program?

the reason you're getting different results because calculator giving sin of 27.5 degrees, whereas google giving sin of 27.5 radians (which equivalent 1576 degrees).

to same result you'll either have change calculator deg mode rad mode, or convince google work in degrees somehow.

as java program, care on site, java's built-in math.sin , math.cos work in radians. if wan't use degrees, you'll have convert them radian form. can either use math.toradians:

math.cos(math.toradians(27.5)) 

or, can use actual math:

math.sin(27.5 * math.pi / 180); 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -