VB.Net input code
Dim TotalRead as UInteger
Dim ContentLenght as UInteger (It is supposed that TotalRead < ContentLength)
Dim porcentage As Integer = Convert.ToInt32((TotalRead / ContentLenght) * 100.0)
In VB TotalRead / ContentLenght is a float number. I guess the operands are converted to float before perform the division. Percentage can take all values between 0 and 100.
Erroneous output
uint TotalRead;
uint ContentLenght;
int porcentage = Convert.ToInt32(TotalRead / ContentLenght * 100.0d);
Here TotalRead / ContentLenght is an integer and porcentaje only takes two values: 0 and 100
Expected output
int porcentage = Convert.ToInt32((double)TotalRead / (double)ContentLenght * 100.0d);
Details
- Product in use: Code Converter (VB - C#) (VS extension)
- Version in use: 9.2.6.0
VB.Net input code
In VB TotalRead / ContentLenght is a float number. I guess the operands are converted to float before perform the division. Percentage can take all values between 0 and 100.
Erroneous output
Here TotalRead / ContentLenght is an integer and porcentaje only takes two values: 0 and 100
Expected output
Details