Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

266
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda