You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The same issue is happening for pydecimal as it was reported for pyfloat: #1928
I think that it should work more straightforward and more reliable, like: we should have a min and max values being updated and only at the end we generate the value.
MIN:
min unset, positive unset, result = minimum calculated from places
min set, positive unset, result = maximum of min and minimum calculated from places
min unset, positive set to True, result = maximum between 0 and minimum calculated from places
min unset, positive set to False, result = minimum calculated from places
min set and positive set to True, result = maximum between 0 and min
min set and positive set to False, result = maximum of min and minimum calculated from places
MAX:
max unset, positive unset, result = maximum calculated from places
max set, positive unset, result = minimum of max and maximum calculated from places
max unset, positive set to True, result = maximum calculated from places
max unset, positive set to False, result = minimum between 0 and maximum calculated from places
max set and positive set to True, result = minimum of max and maximum calculated from places
max set and positive set to False, result = minimum between 0 and max
Afterwards we should check min <= max and then return the random value from this range
I guess this approach is safe and reliable and will indicate about issues in usage when you try to build pydecimal from constrains which produce invalid range
The text was updated successfully, but these errors were encountered:
So, if we get to else statement the sign will choose randomly, and I think that's a bug.
But I was thinking about it and I didn't find any usage for a positive param in pydecimal fucntion.
So let's say we want negative numbers, we set max to 0 and the code should be functioning.
And other hand let's sat I don't want any negatives, so min to 0 and now I know I won't get any.
Or I don't care about the sign, and don't use any of min or max and the code should be random for +, -.
The same issue is happening for
pydecimal
as it was reported forpyfloat
: #1928I think that it should work more straightforward and more reliable, like: we should have a
min
andmax
values being updated and only at the end we generate the value.MIN:
min
unset,positive
unset, result = minimum calculated from placesmin
set,positive
unset, result = maximum ofmin
and minimum calculated from placesmin
unset,positive
set to True, result = maximum between 0 and minimum calculated from placesmin
unset,positive
set to False, result = minimum calculated from placesmin
set andpositive
set to True, result = maximum between 0 andmin
min
set andpositive
set to False, result = maximum ofmin
and minimum calculated from placesMAX:
max
unset,positive
unset, result = maximum calculated from placesmax
set,positive
unset, result = minimum ofmax
and maximum calculated from placesmax
unset,positive
set to True, result = maximum calculated from placesmax
unset,positive
set to False, result = minimum between 0 and maximum calculated from placesmax
set andpositive
set to True, result = minimum ofmax
and maximum calculated from placesmax
set andpositive
set to False, result = minimum between 0 andmax
Afterwards we should check
min
<=max
and then return the random value from this rangeI guess this approach is safe and reliable and will indicate about issues in usage when you try to build pydecimal from constrains which produce invalid range
The text was updated successfully, but these errors were encountered: