par icon indicating copy to clipboard operation
par copied to clipboard

Warning: implicit conversion from 'int' to 'float' (RAND_MAX)

Open powof2 opened this issue 3 years ago • 0 comments

Hi there, par_shapes.h:1103:32:

warning: implicit conversion from 'int' to 'float' changes value from 2147483647 to 2147483648 [-Wimplicit-const-int-float-conversion]
note: expanded from macro 'RAND_MAX'

maybe change like this ? or do a c-style cast for RAND_MAX?

// float r = (float) rand() / RAND_MAX;
float r = rand() / (RAND_MAX + 1.0f); // [0, 1)
float r = rand() / (float)RAND_MAX;  // [0, 1]

powof2 avatar Apr 27 '22 02:04 powof2