0

Why atan(1/2) value and atan(1/3) value are 0?

Why atan(1/2) value and atan(1/3) value are 0? What's the solution? (atan is a function in c++ cmath library for inverse tangent)

24th Jan 2019, 9:24 AM
Hamidreza Abolfathi
Hamidreza Abolfathi - avatar
2 Respostas
+ 5
Because 1/2 and 1/3 are integers, the result is an integer as well. 1/2 = 0.5 => 0 as integer. To get a floating point result you need at least 1 of the 2 operands to be a floating point. e.g. 1/2.0 or 1.0/2 or 1.0/2.0.
24th Jan 2019, 9:30 AM
Dennis
Dennis - avatar
+ 1
Thank you Dennis. 👍
24th Jan 2019, 9:32 AM
Hamidreza Abolfathi
Hamidreza Abolfathi - avatar