FMath::RandRange is broken when the size of the range is more than 0x7FFFFFFF
The way RandRange works is by calculating the size of the difference between the two numbers and using that to produce a random number with a helper function. However, the difference between the two integers is stored as a signed 32-bit integer, which doesn't have a maximum value large enough to cover all use cases.
This code would result in undefined behaviour because (INT32_MAX - -1) = INT32_MAX + 1 which cannot be stored as a 32 bit signed value.
The code might need some rework to fix correctly, so it might be worth warning that such ranges are not supported in the documentation for now.
However, you do make a valid point that this limitation is probably not communicated very clearly. What is your use case where you need a random number within a range greater than 2147483647?
answered Feb 12 '15 at 10:45 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here