>. and <. Operators in Propeller Tool Inconsistent

in Propeller 2
We've discovered an inconsistency between how >. and <. compare constants vs how they compare variables. Here's a code snippet.
Pub FMathAngle(theta) : temp temp := theta if (temp & $8000_0000) ' negative if temp <. -180.0 '(fcmpi(temp, LESSTHAN, -180.0)) repeat temp := temp +. 360.0 'fadd(temp, 360.0) until temp >. -180.0 '(fcmpi(temp, MORETHAN, -180.0)) else if temp >. 180.0 '(fcmpi(temp, MORETHAN, 180.0)) repeat temp := temp -. 360.0 ':= fadd(temp, -360.0) until temp <. 180.0 '(fcmpi(temp, LESSTHAN, 180.0)) return temp
This will NEVER work because >. and <. do not evaluate correctly. To wit if a variable is being compared with a constant they'll want to evaluate false regardless
So for example FMathAngle(400.0) will always return 400.0 instead of in this case, 40.0
Has anyone else seen this?
Comments
This is with Prop Tool, right?
The prop tool compiler is old and new features like floats are buggy there.
Try with PNut, or Flexprop, or Spin Tools, etc.
In case of compiler bugs
- sanity check against the other Spin2 implementations
- whittle the problem down to the shortest possible compilable stand-alone program that reproduces obviously broken behaviour
Unsolicited code review: Question yourself wehter you really want to be storing angles as floating-point degrees. Very likely the answer is no and you probably want to be using binary angles instead. (where this sort of wrapping operation is either not needed or a simple bitwise AND). There are cases for float angles over binary angles in cases where you care about extreme precision at acute angles 0°~1° but nowhere else. Anything where an angle could possibly wrap around multiple times will be faster and higher-precision with binary angles.
Rayman,
That sucks to know that Prop Tool is out of date but thanks for letting those of us who use that it is.
Regarding refactoring floating-point degrees vs binary angles: yeah, there's some math library conversations happening in the shop right now, but ease of debugging is currently winning out over refactoring various math libs.
Also yeah, I'll put a clean bug report together when there's time this just kinda came up right at the end of the day and I figured I'd just see if anybody already knows about it.
It's frustrating because I really like the Alt-select and paste-in-place feature, the bookmarks, and the Summary view in the main window.