32-bit safety in big random number #143
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch fixes a compile-time warning and test case failure on
32-bit architectures, including i386.
The SGD maxIterations parameter to the SGD routine is stored in a
size_t. Arguably inappropriate; it belongs in something guaranteed to
be at least 64 bits, perhaps long long int.
Be that as it may, a test routine was passing a number meant to be so
large it would not be exceeded, to test a mechanism that should
terminate the optimization early. The large number chosen was
10000000000, ten billion, which exceeds the maximum value of an
unsigned 32-bit integer of 4 billion plus change.
This patch changes the maxIterations parameter passed to two billion,
2000000000, which is both sufficiently large for the purposes here and
safely below the maximum value for a 32-bit signed integer.