But, to finally answer your question.

Remainder = %REM(%INT(Premium) : %INT(Instalments))

or if you need remainder to 2 decimals

Remainder = %REM(%INT(Premium*100) : %INT( Instalments *100))/100

Yes, that will burn a few cycles, but what are a few cycles between friends.

The concept that modulus should be based on integers appears to date to the early 1800;s.

Phil

…Which is as it should do. Note that the related %DIV() BIF is also an integer function.

While the MVR op-code would ‘work’ with decimal fractions, you should understand that it is a relatively expensive arithmetic operation. Division of decimal fractions at the binary/bit level is imprecise. Decimal fractions generally do not have precise binary equivalents. Under the covers, the same thing happens with the DIV and MVR op-codes as Phil recommends in his Answer. The values are adjusted to be integers in order to preserve accurate “remainders”.

This is a part of the fundamental incompatibility between the decimal fractions that we (humans) use and the binary representations that computers use.

Try expressing a simple “.3” as a **binary** fraction for example. That might give you an idea of the difficulties involved.

It might appear as if you are drastically slowing down your calculations, but it really doesn’t make that much difference when you need to capture a fractional remainder.

Ideally, you would use redefined variables at the start, and eliminate the need for the “multiply both factors by 100, etc.” piece.

Tom

]]>