godot-docs icon indicating copy to clipboard operation
godot-docs copied to clipboard

`RandomNumberGenerator` - `randi_range` and `randf_range` can swap endpoints

Open elowynd-id opened this issue 1 month ago • 7 comments

Your Godot version: 4.5.1

Issue description: The document for the RandomNumberGenerator class is missing some pieces of information regarding what happens when float randf_range(from: float, to: float) and int randi_range(from: int, to: int) are called with from > to. For randi_range, the documentation of the GobalScope functions explains that the parameters are swapped when such a situation occurs. It seems to be the same for methods from the class RandomNumberGenerator, but the documentation does not mention it. It is not necessarily an obvious behavior. One could, for instance, expect and exception. So I think the documentation of these two methods should mention this behavior.

URL to the documentation page (if already existing): https://docs.godotengine.org/en/latest/classes/class_randomnumbergenerator.html

elowynd-id avatar Oct 25 '25 23:10 elowynd-id