有关于单精度小数在excel中的累加问题
Private Sub Timer1_Timer()Static ElapsedTime As Single
ElapsedTime = ElapsedTime + 0.1
If LeftPictureBox_RUNNING = True Then
Buffer = ElapsedTime & "," & CoordinatesX & "," & CoordinatesY
ElseIf RightPictureBox_RUNNING = True Then
Buffer = ElapsedTime & "," & "," & "," & CoordinatesX & "," & CoordinatesY
End If
TxtFile.WriteLine (Buffer)
End Sub
如图所示,在Timer中进行每次0.1的累加,结果竟然到了2.7的时候,2.7+0.1变成了2.799999
如何解决该问题,敬请各位大侠不吝赐教!!!