VB .NET - Division Wierdness
This is just plain weird. I had a quiz recently in my 306 class and one of the questions asked what would happen if the following code was executed in VB .NET:
x=60\2
I answered that x would not contain 30. I answered this way because in every other programming language I have ever used “\” does not do division, it is an escape character. I got the question wrong so I actually tried putting the code into VB .NET to see the result for myself. Sure enough, using either x=60\2
OR
x=60/2
x ended up with 30!?!? This is because VB .NET uses “” for integer division and “/” for normal division. Since the numbers I chose are integers and the answer is an integer as well, the outcome is the same using either “” or “/”. I don’t mind Microsoft being creative, but I have a problem when their creativity goes against common logic.