Have you ever considered the duality of the *floor* and *modulus* operators, in that either one can be expressed in terms of the other (along with multiply, divide, and a subtraction)?

This became practically important for me when my institution switched from the Blackboard learning management system to Brightspace. Both of these have testing systems with a type of question that presents test-takers with questions incorporating randomly-determined base values, and then automatically check their answers via a mathematical formula set up by the instructor. On Blackboard this type of question is called a "Calculated Formula", and among the supported functions, it includes *floor* but not *modulus*. On Brightspace it's called an "Arithmetic" question, and its list of functions has the inverse coverage: *modulus* but not *floor*.

Now I use this facility to make tests for the introductory C++ programming courses that I teach. Modulus is one of the likely new basic arithmetic operators that we want to test for. Floor is arguably even more essential, in that it's what I need to represent integer division truncation, something really fundamental to how integer math works on a computing system.

So, on **Blackboard**, if I want to test students' knowledge of the behavior of the expression \(a \% b\) (remember that in the students' view, the \(a\) and \(b\) will be filled in with literal numbers), then in the answer formula I have to use the expression: \(a - b * \lfloor a/b \rfloor\).

In other words: Use the floor function to find the largest whole-number of times that \(b\) goes into \(a\), and subtract that maximal product from \(a\), leaving the modulus as a remainder.

Meanwhile, on **Brightspace**, if I want to assess awareness of the truncation that happens automatically with an integer division \(a / b\), then every time that occurs in the answer, I need to make use of the expression: \(a/b - a/b\%1\).

That is: Use modulus by 1 to find the decimal remainder in the ratio \(a/b\), and subtract that from the full \(a/b\), leaving behind only the integer part.

Having translated all of my test questions from one to the other in the last week, I'd say that for CS purposes the floor function is more essential, as it's baked in naturally to any integer math expressions, and so it was overall more natural for the work to be done in Blackboard. Use of modulus is more of a special-case check in my assessments, so that arcane formula only showed up a few times. On the other hand, switching to Brightspace, there were about twice as many instances where I had to conjure a floor truncation via the modulus operator that exists there.

Obviously, it would be best if either system supported both of these basic operators, but as we've discovered, you are operationally complete with either one of the pair.

## No comments:

## Post a Comment