Search Unity

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

Discussion in 'Burst' started by FaithlessOne, May 12, 2023.

  1. FaithlessOne

    FaithlessOne

    Joined:
    Jun 19, 2017
    Posts:
    324
    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:

    Code (CSharp):
    1. Unity.Mathematics.Random random = default;
    2. random.state = 123;
    3. byte deviation = 2;
    4.  
    5. var randomFloat = random.NextFloat(-deviation, deviation);
    6. // 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.
     
  2. tim_jones

    tim_jones

    Unity Technologies

    Joined:
    May 2, 2019
    Posts:
    287
    Thanks @FaithlessOne - we'll track down IN-40909 and have a look at it.
     
    FaithlessOne likes this.