oriches / faker-cs

C# port of the Ruby Faker gem (http://faker.rubyforge.org/)
MIT License
180 stars 52 forks source link

Only generate positive integers #18

Closed nicnz closed 3 years ago

nicnz commented 3 years ago

When calling RandomNumber.Next() 1/2 the time will return a value less than 0

By always converting to an uint, the calculation below then correctly returns a number between 0 and int.max

Siliconrob commented 3 years ago

Can you detail a situation where it generates a negative random number?

Siliconrob commented 3 years ago

I'm thinking about what you stated here, but um you are misleading the input/output because of your (int) type conversion. That should be a uint and you should change of the method signature or at least add to the method comment for intellisense please.