mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -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:
12
net.c
12
net.c
@ -2606,8 +2606,8 @@ static void draw_wires(drawing *dr, int cx, int cy, int radius,
|
||||
|
||||
for (i = 0; i < npoints; i++) {
|
||||
rotated_coords(&xf, &yf, matrix, cx, cy, fpoints[2*i], fpoints[2*i+1]);
|
||||
points[2*i] = 0.5 + xf;
|
||||
points[2*i+1] = 0.5 + yf;
|
||||
points[2*i] = 0.5F + xf;
|
||||
points[2*i+1] = 0.5F + yf;
|
||||
}
|
||||
|
||||
draw_polygon(dr, points, npoints, colour, colour);
|
||||
@ -2747,8 +2747,8 @@ static void draw_tile(drawing *dr, game_drawstate *ds, int x, int y,
|
||||
* rotated by an arbitrary angle about that centre point.
|
||||
*/
|
||||
if (tile & TILE_ROTATING) {
|
||||
matrix[0] = (float)cos(angle * PI / 180.0);
|
||||
matrix[2] = (float)sin(angle * PI / 180.0);
|
||||
matrix[0] = (float)cos(angle * (float)PI / 180.0F);
|
||||
matrix[2] = (float)sin(angle * (float)PI / 180.0F);
|
||||
} else {
|
||||
matrix[0] = 1.0F;
|
||||
matrix[2] = 0.0F;
|
||||
@ -2787,8 +2787,8 @@ static void draw_tile(drawing *dr, game_drawstate *ds, int x, int y,
|
||||
float x, y;
|
||||
rotated_coords(&x, &y, matrix, cx, cy,
|
||||
boxr * points[i], boxr * points[i+1]);
|
||||
points[i] = x + 0.5;
|
||||
points[i+1] = y + 0.5;
|
||||
points[i] = x + 0.5F;
|
||||
points[i+1] = y + 0.5F;
|
||||
}
|
||||
|
||||
draw_polygon(dr, points, 4, col, COL_WIRE);
|
||||
|
Reference in New Issue
Block a user