Try running this in a .VBS file
MsgBox(545.14-544.94)
You get a neat little answer of 0.199999999999932
!
This rounding issue a开发者_如何转开发lso occurs unfortunately in Sin(2 * pi) since VB can only ever see the (user defined) variable pi as accurate as 3.14159265358979.
Is rounding it manually (and loosing accuracy) the only way to improve the result? What is the most effective way of dealing with this kind of problem?
That's the way floating point numbers work, small inaccuracies are to be expected. For nicer output it's easiest to just display the results rounded to fewer digits.
精彩评论