Modulo on decimals

Cringer

ProgressTalk.com Moderator
Staff member
Hi everyone. I'm trying to do a modulo calculation on 2 decimals. Obviously the modulo function doesn't work. I've found knowledgebase article P80755 which doesn't help much.

It suggests using

x - (x / y) * y

But surely (x/y) * y evaluates to x, leaving you with x-x, so therefore 0.

Even if we change it to

(x - (x / y)) * y

we get for example for 3 % 2

(3 - (3 / 2)) * 2.
(3 - 1.5) * 2.
1.5 * 2
3.

Which is also wrong.

So can anyone point me int he direction of a modulo function that would return me

3.75 % 7.5 = 3.75
and
16 % 7.5 = 1
etc

As I would expect it to?
 

Cringer

ProgressTalk.com Moderator
Staff member
Meh it's not pretty, but

lvHoursLeft = TRUNCATE((lvTimeLeft / 7.5 - TRUNCATE(lvTimeLeft / 7.5,0)) * 7.5,2).
 
Top