Use fabs(), not abs() on doubles

This commit is contained in:
Kim Woelders 2020-12-09 17:57:23 +01:00
parent 9b37aee247
commit effc4cc774
1 changed files with 5 additions and 5 deletions

View File

@ -463,9 +463,9 @@ draw_ball(void)
{ {
ball_x = rand() % 39; ball_x = rand() % 39;
ball_y = rand() % 39; ball_y = rand() % 39;
while (abs(d_x) < 0.5) while (fabs(d_x) < 0.5)
d_x = ((double)rand() / RAND_MAX * 4) - 2.0; d_x = ((double)rand() / RAND_MAX * 4) - 2.0;
while (abs(d_y) < 0.5) while (fabs(d_y) < 0.5)
d_y = ((double)rand() / RAND_MAX * 4) - 2.0; d_y = ((double)rand() / RAND_MAX * 4) - 2.0;
blank_buf(); blank_buf();
setup = 1; setup = 1;
@ -623,7 +623,7 @@ aa_line(int x1, int y1, int x2, int y2, unsigned char b,
line_width = (x2 - x1); line_width = (x2 - x1);
line_height = (y2 - y1); line_height = (y2 - y1);
if (abs(line_width) > abs(line_height)) if (fabs(line_width) > fabs(line_height))
{ {
if (x1 > x2) if (x1 > x2)
{ {
@ -639,7 +639,7 @@ aa_line(int x1, int y1, int x2, int y2, unsigned char b,
/* This is currently broken. It is supposed to account /* This is currently broken. It is supposed to account
* for lines that don't span more than one pixel */ * for lines that don't span more than one pixel */
if (abs(line_width) < 0.1) if (fabs(line_width) < 0.1)
{ {
x2 = x1 + 0.5; x2 = x1 + 0.5;
x1 -= 0.5; x1 -= 0.5;
@ -727,7 +727,7 @@ aa_line(int x1, int y1, int x2, int y2, unsigned char b,
} }
/* This is currently broken */ /* This is currently broken */
if (abs(line_height) < 0.1) if (fabs(line_height) < 0.1)
{ {
y2 = y1 + 0.5; y2 = y1 + 0.5;
y1 -= 0.5; y1 -= 0.5;