Hi all,
I've been working on some angle functions and have found what appears to be an error when working with pi. It came up when checking whether an angle is a multiple of 2 pi
For example
(/ (* 22.0 pi) (* 2.0 pi))
returns 11.0, which is what I expected, however
(fix (/ (* 22.0 pi) (* 2.0 pi)))
returns 10.
What's going on? I've tried the same in other applications without issue. It is not an isolated incident. Test function below throws up other ones.
(defun TEST360 (num / count quotient fixpart remainder)
(setq count 1)
(princ "\nCount, Remainder, Quotient, Fixed")
(repeat num
(princ "\n")
(setq quotient (/ (* (float count) pi) (* 2.0 pi)))
(setq fixpart (fix quotient))
(setq remainder (- quotient fixpart))
(princ (itoa count))
(princ ", ")
(princ (rtos remainder 2 8))
(princ ", ")
(princ (rtos quotient 2 8))
(princ ", ")
(princ (itoa fixpart))
(setq count (1+ count))
); end repeat
(prin1)
); end DEFUN TEST360
I also get the same type issues if I use rem instead of fix. Any ideas on why this is occurring, and how to avoid?