-
Notifications
You must be signed in to change notification settings - Fork 3
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
Weights using long #14
Comments
Hey, I limited the weights to int in the beginning, because Fluent Random Picker uses algorithms that sum up all the weights internally. If the int weights are Int32.MaxValue and Int32.MaxValue, the sum can't be stored as an int. So I use long for the sum internally at the moment. If I'd allow long weights and if they are Int64.MaxValue and Int64.MaxValue, the sum can't be stored as a long. I'd need a larger data type then internally... 2 ways are probably possible on my site:
Which .Net version are you targeting? I'll take a closer look at this in the future. |
Hey, Makes sense, you /could/ use BigInteger to sum the values. Tho it might be slow. I'm currently targeting .net 7 rc1. Right now I'm just casting to int so I'm not hindered, but what I'm using it for is figuring out in my game 'who' should hit. Your library just makes mundane stuff easier :D
|
Notes for me:
Math.Pow(0.9999, 1/(double)int.MaxValue) // = 0.99999999999995348165526820594095624983310699462891
Math.Pow(0.9999, 1/(double)long.MaxValue) // = 1.00000000000000000000000000000000000000000000000000
Math.Pow(0.9999, 1/((double)long.MaxValue/10)) // = 1.00000000000000000000000000000000000000000000000000
Math.Pow(0.9999, 1/((double)long.MaxValue/1_000_000)) // = 1.00000000000000000000000000000000000000000000000000
Math.Pow(0.9999, 1/((double)long.MaxValue/10_000_000)); // = 0.99999999999999988897769753748434595763683319091797 So, maybe, there needs to be a fallback like Math.Pow(0.99999999, 1/(double)int.MaxValue) // = 1.00000000000000000000000000000000000000000000000000
Math.Pow(0.99999999, 1/((double)int.MaxValue / 10)) // = 1.00000000000000000000000000000000000000000000000000 BTW: Random.NextDouble being exactly 0 could also be problematic as the result is always 0...
|
Hey,
Is it possible to extend weights to support long, lookg like at the moment they only support int?
❤️
The text was updated successfully, but these errors were encountered: