[IN-40909] Random generation fails for float when using byte parameters

Only want to report a bug in Unity 2022.2.19 and Burst 1.8.4 regarding random generation of Unity.Mathematics.Random. While trying to generate a float value using byte-parameters for min/max the generated number then is no more a float instead looks like an integer:

Unity.Mathematics.Random random = default;
random.state = 123;
byte deviation = 2;

var randomFloat = random.NextFloat(-deviation, deviation);
// Result: randomFloat looks like an integer and is not within the specified min/max

The code still works fine in Mono runtime only.

Created a reproduction project in IN-40909.

Thanks @FaithlessOne - we’ll track down IN-40909 and have a look at it.

1 Like