Quote:
but if i use this function frequently it give 1 for some time but then it return 0
This is a very strange comment because it should always return the same output for the same input.
Nevertheless not all numbers can be exactly represented as a double. This means you end up with something close. For this reason the division or multiplication of 2 numbers sometimes produces a result that appears wrong by a small amount.
When converting a double to an int you must anticipate this. You do this by allowing a margin of error.
A common way is to add a small value. For example
steps = (position / half_angle) + 0.001;