The
result of your calculation[
^] is
14.999999999999998
.
(See What Every Computer Scientist Should Know About Floating-Point Arithmetic[^] if you don't understand why.)
If you truncate that number, you will get
14
.
If you take the floor of that number, you will get
14
.
The
Int
function is equivalent to the
Math.Truncate
function:
Both Int and Fix remove the fractional part of number and return the resulting integer value.
The CInt
function[
^]
rounds the value to the nearest whole number, and is therefore the only version that will produce a result of
15
.
In this specific case, your best option is to rearrange the calculation to
(30 * 500 / 1000)
, or simply replace it with the pre-calculated result of
15
.