New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Random.Decimal with min = 0, max = decimal.MaxValue overflows #319
Comments
Hi Tosil, I think you might be correct. The recent If you could help with a new PR that fixes the Also, @logiclrd if you have any suggestions or comments on the issue, please let us know. Thanks for bringing this to our attention. Brian |
Hi Brian I am not sure what is the best way to fix the overflow and I will not be able to work on this until at least monday, so if you or someone else want to fix it go ahead :). I am happy to help with unit tests or testing later. Thanks! |
I see what the problem is. Still thinking about how to correctly solve it, but the problem is that it's possible for the product of the initial |
(And yes, I wrote that code, so I ought to fix it :-D My apologies) |
…l_with_very_large_range_succeeds to Bogus.Tests. Updated Randomizer.Decimal to make the test pass.
For the time being, I released Bogus The previous Hope this helps. Thanks, |
Thanks for the quick work from both of you! |
Version Information
What locale are you using with Bogus?
en-us
What is the expected behavior?
before v30
faker.Random.Decimal(0m, decimal.MaxValue)
returned a value.What is the actual behavior?
System.OverflowException
Value was either too large or too small for a Decimal.
at System.Number.ThrowOverflowException(TypeCode type)
at System.Decimal.DecCalc.ScaleResult(Buf24* bufRes, UInt32 hiRes, Int32 scale)
at System.Decimal.DecCalc.VarDecMul(DecCalc& d1, DecCalc& d2)
at System.Decimal.op_Multiply(Decimal d1, Decimal d2)
at Bogus.Randomizer.Decimal(Decimal min, Decimal max)
Can you identify the location in Bogus' source code where the problem exists?
https://github.com/bchavez/Bogus/blob/master/Source/Bogus/Randomizer.cs#L195
As I understand there was a change in the randomiser to make double values more precise.
If the bug is confirmed, would you be willing to submit a PR?
Yes
The text was updated successfully, but these errors were encountered: