Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

261
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda