I don't know the delphi implementation, but generally:
round() rounds mathematically down/up, floor() rounds down and ceil() up:
If 'Numerator' and 'Denominator' are integers than don't use these functions because they (and trunc() too) are floating point operators and floating point is not exact (e.g. there is no representation for exact 1/3 or 1/10). Then the usage of the trunc() function ...
... is useless, because integer division is always rounded down. The trunc() only forces a int to float to int operation.
Again: I don't know the delphi internals, but all above is common to many programming languages.
round() rounds mathematically down/up, floor() rounds down and ceil() up:
Code:
ÂÂxÂÂ floor(x)ÂÂround(x)ÂÂceil(x)
----------------------------------
1.0ÂÂÂÂ1.0ÂÂÂÂÂÂ 1.0ÂÂÂÂÂÂ1.0
1.3ÂÂÂÂ1.0ÂÂÂÂÂÂ 1.0ÂÂÂÂÂÂ2.0
1.5ÂÂÂÂ1.0ÂÂÂÂÂÂ 2.0ÂÂÂÂÂÂ2.0
1.7ÂÂÂÂ1.0ÂÂÂÂÂÂ 2.0ÂÂÂÂÂÂ2.0
2.0ÂÂÂÂ2.0ÂÂÂÂÂÂ 2.0ÂÂÂÂÂÂ2.0
If 'Numerator' and 'Denominator' are integers than don't use these functions because they (and trunc() too) are floating point operators and floating point is not exact (e.g. there is no representation for exact 1/3 or 1/10). Then the usage of the trunc() function ...
Code:
result := trunc((Numerator + Denominator - 1) / Denominator);
Again: I don't know the delphi internals, but all above is common to many programming languages.