Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

259
Views
Tan() function returns wrong value

I got a problem with some code, but can't find the error. I'm trying to calculate the distance marked in red on the sketch below.

My code return the value: -41.63

Correct value is: 3.75

My code:

return round(6.5 * tan(30),2);

Based on: http://php.net/manual/en/function.tan.php

enter image description here

I thought was was going to be a simple task, but i hit a wall - can't see the error. I hope some of you can point me in the right direction.

Thanks,

Kenneth

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

The arg parameter is in radians.

tan()

You're sending the number of Degrees and the function expect Radians, so convert your value from Degrees to Radians first and you will get the expected result.

return round(6.5 * tan(deg2rad(30)),2);   //3.75

Fiddle

about 4 years ago · Santiago Trujillo Report

0

Your current value is number of degrees and you need to convert this to radians first. Use deg2rad() function inside tan() to convert value from Degrees into Radians.

deg2rad(): Converts the number in degrees to the radian equivalent

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!