Cutting down motor power

I’ve encountered a problem with reducing the power on motor outputs when slowing the robot down for demos. The original lines of code are:
which run the lift at full speed as expected. When I change it to:
the lift runs slightly slower, which makes sense. Now where it starts making less sense. When I change it again to:
it runs slower than dividing by 5/3, which it shouldn’t. The worst one is:
which causes the lift to stop responding to input altogether. Has anyone else encountered this, does anyone know why this happens, and is there a way to make dividing by 5/3, multiplying by 0.6, and multiplying by 3/5 all do the same thing?

You are likely running into problems with integer division. If you do not put decimal points on your numbers, the compiler will assume that you are using integers. In integer land, multiplying by 5/3 is the same as multiplying by 1, which should cause no change in the elevator motion, and multiplying by 3/5 is the same as multiplying by 0, which explains your lack of elevator movement.

You have already found the easiest solution, which is to just use 0.6 instead of 3/5. If you want to use 3 and 5, write them as 3.0 and 5.0, which will tell the compiler that these are floating point numbers, and thus can have a floating point quotient.

Another way is shown below, not perfect but the way you’d do it if you really did want to do integer arithmetic:


This way multiplies by 3 and then divides by five. In integer arithmetic (especially division), the order of operations absolutely matters.