When adding 2 values in vb6 i get some odd behavior.
When variable sum (type double) is printed for different cases in immediate window as below.
I got results as :
sum =0 sum =0 sum =0
sum =74.46+0.41 sum = 74.87 sum=97.8+0.41
?sum ?sum =74.87 ?sum
74.87 TRUE 98.21
?sum =74.87 sum=98.21
FALSE TRUE
When checked the same in vb.net we get the result as below:
sum =0 sum =0 sum =0
?sum sum = 74.87 sum=97.8+0.41
0 ?sum =74.87 ?sum
sum =74.46+0.41 TRUE 98.21
?sum ?sum=98.21
74.8699999999999 TRUE
From the above result we can say the result "False" since in vb6 the value is equal to 74.8699999999999.
- Then why in vb6 result shown as 74.87?
- In vb.net case expected value =74.87 but actual value =74.8699999999999 why the error occurs only for certain values ?
- This kind of behavior occurs for which values?