I recently made an error that had me puzzled for a while. It didn't generate any compiler errors, or run time errors, it just gives wildly incorrect values.
What I did was assign an integer plus a float to an integer (stupid I know).
Here is the example:
Dim Temp_Sample_Time As Integer = (2 * getTemperaturesamplingValue()) + 0.5
Even if you do this:
Dim Temp_Sample_Time As Integer = ((2 * getTemperaturesamplingValue()) + 0.5).ToInteger
or this:
Dim Temp_Sample_Time As Integer = ((2 * getTemperaturesamplingValue().ToFloat) + 0.5).ToInteger
It doesn't work (but no errors).
Converting a Float to Integer using Float.ToInteger gives weird results (i'm sure it make sense from a bitwise point of view).
getTemperaturesamplingValue() returns an Integer in the range 0 to 16. The above code set "Temp_Sample_Time" to some huge number, and sent the program off into neverland.
Dim Temp_Sample_Time As Float = (2 * getTemperaturesamplingValue()) + 0.5
The above is correct (although I re-wrote this differently in the end).
Just a note to the wise.