Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cos() returning wrong number...

Status
Not open for further replies.

blairacuda

Technical User
Sep 3, 2009
51
US
Hello All,

When I run Cos(45) I get .53 in return but plugging it into my calculator returns .7071...etc. I am expecting the .7 number.

I can't find a different function for cosine...

Any help would be great. Thanks in advance.

-Chris
 
My calculator gives me what Crystal does:
cos(45) = 0.5253

AndyMc
 
Cos returns a Number specifying the cosine of an angle given in radians. It takes a right-angle triangle, and returns the length of the side adjacent to the specified angle divided by the length of the hypotenuse.

cos(45 radians) = 0.5253

cos(45 degrees) = 0.7071

Crystal does radians and my calculator defaults to radians. From what I can gather radians is the standard in Trig.

AndyMc
 
this should get you what you want

convert your degrees to radian like this
45*(crpi/180)

then take your cosine like this

cos(45*crpi/180)

that equals .7071

_____________________________________
Crystal Reports XI Developer Version
Intersystems Cache 5.X ODBC connection

 
crpi is the crystal reserved word for pi by the way

_____________________________________
Crystal Reports XI Developer Version
Intersystems Cache 5.X ODBC connection

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top