+ 1

we know that tan(π/2)= infinity. but this code in description prints it's value, 16331239480885248.000000. Why?

#include <stdio.h> #include <math.h> int main(){ float x = tan(M_PI/2); printf("%f", x); return 0; } output: 16331239480885248.000000

30th Jul 2020, 12:45 PM
Jilani Hasan
Jilani Hasan - avatar
4 ответов
+ 2
I think that's because the program is only using π's approximation. tan(1.5707963267948966) is not infinity, because it's not tan(π/2).
30th Jul 2020, 1:04 PM
Seb TheS
Seb TheS - avatar
+ 3
Jayakrishna🇮🇳 I think you mean *Radians* instead of radius
30th Jul 2020, 1:09 PM
Arsenic
Arsenic - avatar
+ 2
M_PI value you get 3.14 (may it in radians, if not then also not equal to 90° degrees) .
30th Jul 2020, 1:06 PM
Jayakrishna 🇮🇳
+ 1
Yes. Arsenic ... Edited
30th Jul 2020, 1:14 PM
Jayakrishna 🇮🇳