+ 1

How to generate random decimal numbers

Doesn't look like Random.Next() has the option to generate decimals apart from integers Any answer is appreciated 😉

2nd Sep 2021, 7:53 PM
Tim
Tim - avatar
15 Respuestas
+ 4
Lisa Your method works perfectly fine 👍 https://code.sololearn.com/c2XaDFdrsLop/?ref=app
3rd Sep 2021, 5:20 AM
Tim
Tim - avatar
+ 3
Why not generate integers and then divide them? Can you specify what sort of numbers you want? edit: what did you try to google? "cs random decimals" got me this: https://stackoverflow.com/questions/609501/generating-a-random-decimal-in-c-sharp
2nd Sep 2021, 8:26 PM
Lisa
Lisa - avatar
+ 3
Martin Taylor, thanks for the formatting too 😉, didn't know you could do :F after a number
3rd Sep 2021, 5:10 PM
Tim
Tim - avatar
+ 3
This thread is about generating random numbers in C#, not about Lua or playground or web. So what does ChillPill's Lua demo do here?
4th Sep 2021, 11:27 AM
Lisa
Lisa - avatar
+ 2
Just out of curiosity: What do you need the random decimals for? (And actual decimals or just some floating point number type?)
3rd Sep 2021, 5:02 AM
Lisa
Lisa - avatar
+ 2
Lisa Any decimal that's not an integer, couldn't come up with a better term so my apologies for making it confusing.
3rd Sep 2021, 5:03 AM
Tim
Tim - avatar
+ 2
Thank you, Martin Taylor
3rd Sep 2021, 10:23 AM
Tim
Tim - avatar
+ 2
How is the lua code related to the question of this thread? Please don't post non-related codes.
4th Sep 2021, 11:14 AM
Lisa
Lisa - avatar
+ 1
Thanks, just trying to find something new, the method Lisa came up with is very clever and the link she provided is mind boggling 👍
3rd Sep 2021, 4:31 AM
Tim
Tim - avatar
+ 1
Lisa And I needed them to display the possibility of chosen items, the output should look like this: first - 42.5% second - 57.5% ... maybe even more depending on the amount Not sure how to implement it properly though
3rd Sep 2021, 5:05 AM
Tim
Tim - avatar
+ 1
Thank you, Martin Taylor, what is the use of ⚡decimal numbers in the program.📜
4th Sep 2021, 11:08 AM
Shubham Bhatia
Shubham Bhatia - avatar
+ 1
This is only for the sololearn code playground ⚡⚡
4th Sep 2021, 11:24 AM
Shubham Bhatia
Shubham Bhatia - avatar
4th Sep 2021, 11:09 AM
Shubham Bhatia
Shubham Bhatia - avatar