Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Open
powof2 opened this issue Apr 27, 2022 · 0 comments
Open

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

powof2 opened this issue Apr 27, 2022 · 0 comments

Comments

@powof2
Copy link

powof2 commented Apr 27, 2022

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]
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant