[metapost] Strange result for angle() in MP 1.750

Dan Luecking luecking at uark.edu
Tue Dec 6 18:43:47 CET 2011

```In metapost version 1.750 (just downloaded off SupelectFoundry):
*show angle (up);
gives me
>> 1440
This is not only an incorrect angle (dir 1440 = right),
but not in the documented range of -180 to 180.

Version 1.504 correctly produces 90.
Here is some more lunacy regarding angle():
*show angle (.3,1);
>> 1172.80957
*show angle (.5,1);
>> 1014.95923
*show angle (1,.8);
>> 618.55861
*show angle (1,.6);
>> 495.4242
*show angle (1,.4);
>> 348.81773
*show angle (1,.2);
>> 180.9562
*show angle (1,.1);
>> 91.375
*show angle (1,0);
>> 0
(The last one shows only that even an incorrect calculation
can occasionally produce a correct answer.)

These numbers appear to all be off by a factor of 16,
suggesting the bug is a simple oversight in the implementation
of Knuth's algorithm. His algorithm treats angles internally
as integer multiples of 2^{-20}, making them 16 times the
usual numerics which are integer multiples of 2^{-16}.

Regards,
Dan

Daniel H. Luecking
Department of Mathematical Sciences
Fayetteville, Arkansas
http://www-cs-faculty.stanford.edu/~knuth/iaq.html

```