-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed as not planned
Labels
area-System.NumericsquestionAnswer questions and provide assistance, not an issue with source code or documentation.Answer questions and provide assistance, not an issue with source code or documentation.
Description
This is a simplified expression of a complex code path we found in our code base while migrating to .NET 10:
(uint)(((double)random.Next() + (uint)random.Next()) * random.Next())
This always returns the same magic number in .NET 9 and later version whatever the Random instance used: 4294967295. It returns random results in .NET Framework or .NET Core until version 8.
We found that by chance and will workaround it on our own. I guess the same returned value is caused by a sequence of casts, but I was curious as to why the behavior changed in .NET 9. Please tell me if this is not the right place for this question.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area-System.NumericsquestionAnswer questions and provide assistance, not an issue with source code or documentation.Answer questions and provide assistance, not an issue with source code or documentation.