modulo operator %

hy there,  I apologize in advance for the silly question, but

8.66 % 3 should be 2.66

as a matter of fact it is equal to $8.66 - 3 \cdot trunc(\frac{8.66}{3})$ = 2.66

I have checked it also with the remainder function in OpenOffice calc and it gives 2.66

Gauss, instead, gives: 8.66%3 = 0.0000

Am I using it the wrong way?

Is there a way to get the same result as in OpenOffice Calc with % in Gauss ?

Thanks in advance for your reply.


2 Answers


The modulo operator operates on integers. In your example 8.66 is being rounded to 9 and (9 % 3) = 0 so, that explains what you are seeing. If you want a decimal or floating point modulus operation, use the function fmod.

r = fmod(8.66, 3);
print r;

will return:


Thanks a lot, I really appreciate.

You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.

Try GAUSS for 14 days for FREE

See what GAUSS can do for your data

© Aptech Systems, Inc. All rights reserved.

Privacy Policy