Integer Division Rounding Type

25 views
Skip to first unread message

Imko Marijnissen

unread,
Jun 6, 2024, 7:17:19 PMJun 6
to MiniZinc
Good day,

In the MiniZinc specification, it is not specified what type of division is performed when using the constraint `int_div` and different solvers implement different forms of rounding (e.g. Chuffed uses floored division while Gecode and OR-tools implement truncating division).

I saw in a previous thread that it was stated that "The semantic of the 'div' operator is to truncate the result of the real division", does this mean that `int_div` should implement truncating division?

Thank you in advance for your answer!

Kind regards,
Imko Marijnissen

Jip Dekker

unread,
Jun 7, 2024, 4:38:48 AMJun 7
to MiniZinc
Hi Imko,

The correct behaviour is indeed to "truncate" when rounding the result. This is also the behaviour when dividing using parameter values:

any: x ::output = [i: i div 3 | i in -10..10];

I will update the documentation to reflect this.

Cheers,
Jip
Reply all
Reply to author
Forward
0 new messages