All of these references are then cast to Integer
or Long
:
CInt
and CLng
explicitly call Math.Round
before their corresponding IL conv.ovf.i4/8
cast when casting from Single
and Double
.
This enforces the Banker's Rounding that is a VB.NET known "quirk".
conv.ovf.i4
alone truncates towards zero, which happens to be the same as Fix
(for the numbers that fit in an Integer
, or a Long
for conv.ovf.i8
).
(When I originally typed in the question I thought I had checked that this was not the cause.)
For a while, Microsoft made the Reference Source available, so I was able to confirm they were all enclosed in CInt
or CLng
and the Math.Round
is added by the compiler.
The VB.NET "source" currently available at the above link now only provides the "reference assembly" which has no code :-(
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…