Home > Software engineering >  VB6 debugging and encounter the problem of 8.16-8-0.16 is not equal to zero
VB6 debugging and encounter the problem of 8.16-8-0.16 is not equal to zero

Time:09-16

VB6 programming, debugging and encounter a problem: 8.16-8 * 8-0.02, the result is equal to 1.38777878078145 e-16 how be to return a responsibility? I write it as - 8-0.16, 8.16 or 1.38777878078145 e-16 result, is not zero, why?


CodePudding user response:

? @ 8.16-8-8 * 0.02 @ 
0

? 8.16-8-8 * 0.02
1.38777878078145 e-16


Can consider to use Currency type

CodePudding user response:

Results not to 0 because floating point precision problem caused by the transformation,

CodePudding user response:

1.38777878078145 e-16
This is 0, just have error, the equivalent of 1.3877... X10-16 power, infinite close to zero
  • Related