|
-
Oct 30th, 2024, 02:29 AM
#5
Re: VB.net VS2022 => How to generate random number that is a Single or Double
Note that both RandomNumberGenerator and Random can generate random Bytes, so you can use those Bytes any way you want, e.g. use BitConverter to convert four Bytes to a Single. That said, you'd probably just use Random.NextDouble and Convert.ToSingle, if a Single is what you need.
Note also that the Random class has had a Shared property since .NET 6, so you don't need to create your own instance anymore, unless you need multiple different instances or to specify your own seed.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|