Sfoglia il codice sorgente

Fixed Math.random().

Steven Hall 8 anni fa
parent
commit
c8fbdb096e
1 ha cambiato i file con 1 aggiunte e 1 eliminazioni
  1. 1 1
      src/optionals/gravity_math.c

+ 1 - 1
src/optionals/gravity_math.c

@@ -517,7 +517,7 @@ static bool math_random (gravity_vm *vm, gravity_value_t *args, uint16_t nargs,
     }
     
     int r = rand();
-    RETURN_VALUE(VALUE_FROM_FLOAT(r / RAND_MAX), rindex);
+    RETURN_VALUE(VALUE_FROM_FLOAT((float)r / RAND_MAX), rindex);
 }
 
 // rounds x to the nearest integer