Browse Source

Fix numeric conversion warnings in example

(cherry picked from commit df15a33e1035d47c223e83ecd4018e392c851969)
Camilla Löwy 4 years ago
parent
commit
45336c1104
1 changed files with 5 additions and 5 deletions
  1. 5 5
      examples/heightmap.c

+ 5 - 5
examples/heightmap.c

@@ -292,12 +292,12 @@ static void generate_heightmap__circle(float* center_x, float* center_y,
 {
 {
     float sign;
     float sign;
     /* random value for element in between [0-1.0] */
     /* random value for element in between [0-1.0] */
-    *center_x = (MAP_SIZE * rand()) / (1.0f * RAND_MAX);
-    *center_y = (MAP_SIZE * rand()) / (1.0f * RAND_MAX);
-    *size = (MAX_CIRCLE_SIZE * rand()) / (1.0f * RAND_MAX);
-    sign = (1.0f * rand()) / (1.0f * RAND_MAX);
+    *center_x = (MAP_SIZE * rand()) / (float) RAND_MAX;
+    *center_y = (MAP_SIZE * rand()) / (float) RAND_MAX;
+    *size = (MAX_CIRCLE_SIZE * rand()) / (float) RAND_MAX;
+    sign = (1.0f * rand()) / (float) RAND_MAX;
     sign = (sign < DISPLACEMENT_SIGN_LIMIT) ? -1.0f : 1.0f;
     sign = (sign < DISPLACEMENT_SIGN_LIMIT) ? -1.0f : 1.0f;
-    *displacement = (sign * (MAX_DISPLACEMENT * rand())) / (1.0f * RAND_MAX);
+    *displacement = (sign * (MAX_DISPLACEMENT * rand())) / (float) RAND_MAX;
 }
 }
 
 
 /* Run the specified number of iterations of the generation process for the
 /* Run the specified number of iterations of the generation process for the