By using a simple loop to keep dividing 10 by 2, I get these results:
5-2-1
Whereas I should get: 5-3-2-1 (for example:5/2 = 2.5 since it is an integer
it must be rounded to 3)
How this happens?
Or how integers division works?
Thank you.
5-2-1
Whereas I should get: 5-3-2-1 (for example:5/2 = 2.5 since it is an integer
it must be rounded to 3)
How this happens?
Or how integers division works?
Thank you.
Code:
Dim digit As Integer
dim result as integer
Integer.TryParse(txtDigit.Text, digit)
Do
result = digit / 2
digit = result
txtDisplay.Text += result.ToString & vbNewLine
Loop Until digit = 1