Use the modulo operator
In [1]: 4.5 % 1.5
Out[1]: 0.0
https://en.wikipedia.org/wiki/Modulo_operation
https://docs.python.org/3/reference/expressions.html?highlight=modulo#binary-arithmetic-operations
On Sun, 21 Mar 2021 at 23:47, Jacob Rief wrote:
> Say, you have a value and step, both are flo
Week ending March 21, 2021
*Triaged: *
https://code.djangoproject.com/ticket/32547 -
assertHTMLEqual()/assertHTMLNotEqual() allow invalid HTML. (accepted)
https://code.djangoproject.com/ticket/32549 - Add `Q.empty()` to check
for nested empty Q objects like `Q(Q())` (wontfix)
https:/
The problem with modulo on floats is, that due to rounding errors it often
created weird results,
for instance in Python-3.8 this happens: 3.5 % 0.1 = 0.09981
This btw. also applies to the builtin divmod and math.fmod functions.
Therefore I proposed to do it via classic division and ch
There are ways to check "close enough" equality for floats. There's
even the math.isclose() function which is arbitrarily tune-able:
https://docs.python.org/3/library/math.html#math.isclose
--
You received this message because you are subscribed to the Google Groups
"Django developers (Contrib
I do something similar to what math.isclose() provides. Can anyone please
review this PR:-
https://github.com/django/django/pull/14162
On Mon, Mar 22, 2021, 4:53 PM James Bennett wrote:
> There are ways to check "close enough" equality for floats. There's
> even the math.isclose() function which