I was creating a check to see if a number is a multiple of 0.1. For example, 56, 56.1, and 56.5 would work, but not 56.11, since it is a multiple of 0.01, but not 0.1. I thought I could use modular arithmetic to check for this using this expression:
number mod 0.1
Normally, when a number is evenly divisible by the number it is being modulated by (if that is the right term), the expression returns 0 (e.g. 10 mod 2 is 0, 16.5 mod 0.25 is 0, etc). However, however, when I do mod 0.1, it returns 0.1 when it is evenly divisible. For example, when "number" has a value of 56, 56.1, and 56.5, the expression returns 0.1, while 56.11 mod 0.1 has a value of 0.01.
I have tried this with other decimal numbers, and for some reason. modulating by 0.1 is the only case where it is evenly divisible if the expression returns 0.1 instead of 0.
I do not need to know this for a project or school, but it would be nice to know, and I can't seem to find the answer. Thanks!