Simple integer division question

Apologies for such a basic question - I haven't been able to find an answer anywhere.

I'm wondering how Arduino handles fractions of integers.

I'm using Arduino to run a 12 bit TLV5618 DAC (0-4095) - when I set the output value to, for example, 4095/2 - am I getting 2047.5 or does Arduino round it up/down to a 'whole' integer?

If it is actually a fraction - how many decimal places would it go to?

Hope that makes sense - thanks.

J

If the numerator is an integer, and the denominator is also an integer, the result will be an integer, too. In integer division, any fractional part is truncated. There is no rounding.

Thanks Paul - that's excellent.

So 2047.5 would be truncated to 2047 and 912.3127 would be truncated to 912?

Appreciated.

J

yes