How do we deal with units when using the modulo operation?

431 Views Asked by At

I'm wondering how I should deal with units when I do a modulo operation. What is considered legal and what is not.

When I have two numbers that have units such as 13cm and 3cm, I can multiply them:

$$13cm \times 3cm = 39cm^2 $$

Similarly, I can do divisions:

$${39cm^2 \over 3cm} = 13cm$$

Now, I'm wondering what can I do with modulo. It seems to me that only distance less numbers can be used on the right side of the operation and the result keeps the same unit as the left side.

$$39cm \bmod 5 = 4cm$$

Is that correct? Where could I find information about dealing with units and all operators (relations, additions, multiplication, divisions, modulo, power, etc.)

2

There are 2 best solutions below

3
On BEST ANSWER

When I write $$39\mod{5}=4$$ what I am saying is that there is some integer $k$ such that $$39=5k+4$$

Hence the only way I can make sense of units associated to the mod function is if all of $39, 5, 4$ have the same units (while $k$ is dimensionless). Hence I would write $$39cm \mod{5 cm}=4cm$$

2
On

Typically, two values with the same dimension (length, time, current squared over kilogram, etc) can be added or subtracted, and two values of any dimension can be multiplied or divided. Other operations generally don't behave so nicely, but there is a workaround.

Let $x$ be the length of whatever in centimetres. Then if the object has length L, $x = L/1\ cm$. $x$ is a dimensionless value, which means you can work with it in modulus equations (and other functions that don't like units, like $e^x$ and $\cos(x)$). It also has the neat property that it doesn't actually matter what units $L$ is expressed in - if $L = 1\ inch$, then $x = 1\ inch/1\ cm = 2.54\ cm/1\ cm = 2.54$.