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 <jacob.r...@gmail.com> wrote:

> Say, you have a value and step, both are floats, then if value / step is
> can be represented
> integer, the validation is fulfilled. Otherwise if the result has to be
> rounded to become an integer,
> a ValidationError shall be raised.
> Be aware of rounding errors.
>
> On Sunday, March 21, 2021 at 9:53:43 PM UTC+1 kapilbansal...@gmail.com
> wrote:
>
>> Hi everyone,
>> I am working on this and I have a question.
>> How to write validation check for this?
>> Due to python floating point issues, I am not able to validate whether
>> field value is of given step_size or not
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-developers+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/11953496-ad4c-49cd-857d-e8723692197bn%40googlegroups.com
> <https://groups.google.com/d/msgid/django-developers/11953496-ad4c-49cd-857d-e8723692197bn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Adam

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAMyDDM0DLU2Pbr%3D9HCwT0fGq5qtCeyP4rEyqrCSasFCqaTQkLA%40mail.gmail.com.
  • Re:... Markus Holtermann
    • ... Jacob Rief
      • ... Josh Smeaton
        • ... Carlton Gibson
          • ... Jacob Rief
            • ... Carlton Gibson
              • ... 'Adam Johnson' via Django developers (Contributions to Django itself)
              • ... Jacob Rief
              • ... Kapil Bansal
              • ... Jacob Rief
              • ... 'Adam Johnson' via Django developers (Contributions to Django itself)
              • ... Jacob Rief
              • ... James Bennett
              • ... Kapil Bansal

Reply via email to