-
Notifications
You must be signed in to change notification settings - Fork 887
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Define proper and portable constants #151
Comments
vchizhov
referenced
this issue
in vchizhov/InOneWeekend-1
Aug 23, 2019
Compiles with no warnings on MSVC 2019 with Warning Level: /W4. - provided CMakeLists.txt (tested only on Windows 10 with MSVC 2019 though, create the project in /build so that it would be ignored by the gitignore) - changed M_PI with a constexpr pi<T>() function - substituted random_double() and drand48() with my own random() function using the Mersenne twister from the standard library - use fstream rather than cout, so that redirecting would not be required - fixed double/float mismatch Removed random.h since it is redundant - I substituted random_double() with my own random() implementation using the Mersenne twister from the standard library. The random_double() in random.h used rand() % (RAND_MAX + 1.0); which is suboptimal (fails multiple statistical tests).
@hollasch Mind if I take this? I will try to make all code compile and run on Windows/Linux/Mac and I think this is part of that. I'll assign to myself, but please reassign if you have already started or want to work on this. |
Sweet — thanks Ronald! |
Fixed on the |
Now in the development branch. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The current code base uses
M_PI
andMAXFLOAT
. Both of these should be simple C++ constants defined somewhere. This may induce the need for a new common header (constants.h
?).Also note that
MAXFLOAT
, in addition to not being portable, also defines the maximum representable finite floating-point value. It should really be replaced with infinity (of the appropriate precision).The text was updated successfully, but these errors were encountered: