In VB.NET even if both the operands are integer, the /
operator will cause the value to be floating point (if the result is non integer).
So I tried with the \
operator which yields integer value irrespective of the operands.
So I thought \
is integer division.
2.5 \ 3
results in 0
.
Now I tried 1.5 \ 2
. I expected it to be 0
but it resulted in a 1
.
Now, is it a bug or a correct result?
What the \
operator actually is?
If it's a bug it exists right through VB6.
If you use \
on non-integers, you first convert them to integers, which causes rounding: the equivalent of CLng(1.5) \ 2
, which is 2 \ 2
or 1
.
If you use Option Strict On
then you will see this taking place.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With