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)

2 Answers

+ 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.

+ 1

Thank you Dennis. đ