I found a bug in Math.Angle
Watch this bug in action:
Angle ang = Angle(); ang->set("deg",90); write(ang->get("rad") + "\n"); ang->set("deg",90); write(ang->get("rad") + "\n");
The problem:
Angle set_rad(int|float rad) { angle = rad; normalize(); type = "rad"; // this should be before the normalize() call return this_object(); }
The solution:
Angle set_rad(int|float rad) { angle = rad; type = "rad"; normalize(); return this_object(); }
Do the same with set_gon and set_degree also.
Another note: The following line causes normalize() to be called before 'type' is set to anything. So the switch(type) statement in normalize() doesn't do anything to make sure the angle is within range.
Angle ang = Angle();
C-Ya, David Newmon (dnewmon@yahoo.com)
These are all already fixed in the CVS.
/ Martin Nilsson (Fake Build Master)
Previous text:
2002-11-11 00:13: Subject: 'Outsider finds a bug and fix'
I found a bug in Math.Angle
Watch this bug in action:
Angle ang = Angle(); ang->set("deg",90); write(ang->get("rad") + "\n"); ang->set("deg",90); write(ang->get("rad") + "\n");
The problem:
Angle set_rad(int|float rad) { angle = rad; normalize(); type = "rad"; // this should be before the normalize() call return this_object(); }
The solution:
Angle set_rad(int|float rad) { angle = rad; type = "rad"; normalize(); return this_object(); }
Do the same with set_gon and set_degree also.
Another note: The following line causes normalize() to be called before 'type' is set to anything. So the switch(type) statement in normalize() doesn't do anything to make sure the angle is within range.
Angle ang = Angle();
C-Ya, David Newmon (dnewmon@yahoo.com)
/ dnewmon
pike-devel@lists.lysator.liu.se