mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-20 23:51:29 -07:00
Convert a lot of floating-point constants to single precision
For reasons now lost to history, Puzzles generally uses single-precision floating point. However, C floating-point constants are by default double-precision, and if they're then operated on along with a single-precision variable the value of the variable gets promoted to double precision, then the operation gets done, and then often the result gets converted back to single precision again. This is obviously silly, so I've used Clang's "-Wdouble-promotion" to find instances of this and mark the constants as single-precision as well. This is a bit awkward for PI, which ends up with a cast. Maybe there should be a PIF, or maybe PI should just be single-precision. This doesn't eliminate all warnings from -Wdouble-promotion. Some of the others might merit fixing but adding explicit casts to double just to shut the compiler up would be going too far, I feel.
This commit is contained in:
@ -1605,7 +1605,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
|
||||
* end up the right way round. */
|
||||
angle = atan2(dx, -dy);
|
||||
|
||||
angle = (angle + (PI/8)) / (PI/4);
|
||||
angle = (angle + (float)(PI/8)) / (float)(PI/4);
|
||||
assert(angle > -16.0F);
|
||||
dir = (int)(angle + 16.0F) & 7;
|
||||
}
|
||||
|
Reference in New Issue
Block a user