Open DuneTruffle opened 4 months ago
For GDScript use print(randi_range(pow(2, 31), pow(2, 31)))
The lower bound is the same as the upper bound here, so you'll always get the same value.
For GDScript use print(randi_range(pow(2, 31), pow(2, 31)))
The lower bound is the same as the upper bound here, so you'll always get the same value.
Oh sorry, late night brain doing its wonders! the GDScript version works, but the C# one does not. and i have tested GD,RandRange a lot.
i updated the post. the issue still remains with C# GD.RandRange
Looks like it could be an overflow due to this code: https://github.com/godotengine/godot/blob/e25f3c0d38d457b15a63720240736f564ce0501b/core/math/random_pcg.cpp#L78
Wanted to add some clarity here that this is broken for gdscript as well, for example randi_range at 32 bit signed int limits returns weird results
randi_range(-2147483647, 2147483646)
Tested versions
requires C# version as the the issue is related to C# Godot v4.3.dev5.mono - Windows 10.0.22631 - GLES3 (Compatibility) - NVIDIA GeForce GTX 1650 (NVIDIA; 31.0.15.5176) - 13th Gen Intel(R) Core(TM) i5-13600KF (20 Threads)
System information
Godot v4.3.dev5.mono - Windows 10.0.22631 - GLES3 (Compatibility) - NVIDIA GeForce GTX 1650 (NVIDIA; 31.0.15.5176) - 13th Gen Intel(R) Core(TM) i5-13600KF (20 Threads)
Issue description
C# GD.RandRange is broken when using the minimum and maximum value of the int type it returns the same number always, which is some big negative number
Steps to reproduce
get the specified version.
in ready function use the following code line, run the scene a few times. you will get the same number after the first run use GD.Print(GD.RandRange(int.MinValue, int.MaxValue));
Minimal reproduction project (MRP)
requires C# version of godot! create a new project and simply use GD.Print(GD.RandRange(int.MinValue, int.MaxValue)); in ready or anywhere.