Why do only similar numbers appear in rand()?

Asked 1 years ago, Updated 1 years ago, 108 views

I don't know if seed is weird or if I pull land() I keep getting similar numbers.

In my program, I'm going to write a log, so there needs to be a big difference Almost all of them are from 225 to 230

2530

What's wrong?

c c++ math random

2022-09-22 15:09

1 Answers

rand can extract numbers from 0 to 230.

30

If you look at the percentage of the numbers you take out, About 3% is between 0 and 224, and the remaining 97% is between 225 and 230 When you take the log, it's normal to get almost 25 to 30.

242530

(225 / 230 = 2-5 = 1/32 = 0.03125 = 3.125%)

2530-5


2022-09-22 15:09

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.