VB the VB 排除在 这不是一个错误,只是(在我看来)他们的一个愚蠢的决定。无论如何,使用格式函数(没有格式说明符),因为它使用正常四舍五入而不是银行家的舍入(你将其称为错误)。例如, Debug.Print格式(2.5) Rick - MVP It''s not a bug, just (in my opinion) a dumb decision on their part. Anyway, use the Format function (without a format specifier) as it uses "normal" rounding rather than the Banker''s Rounding (which you are referring to as a "bug"). For example, Debug.Print Format(2.5) Rick - MVP 谢谢Rick .. 不,我不是指银行家的四舍五入,我指的是VB内部 糟糕的浮点错误。 由于 底层代码中存在错误,导致VB的数学函数出现问题。例如,如果你这样做??圆形(68.505,2) 你得到68.5,这是不正确的;因为如果你将68.505舍入到两位小数 分,你应该得到68.51。 这是因为计算的基础代码: ? int(68.505 * 100 + .5)/ 100 给出68.5! 这里可以看到一个更严重的错误: ? int(68.505 * 1000 + 5) 68509 !!! (应该是68510) 因此,分数的乘法因子越大,误差越大 (上述误差是一个完整的一个)。 但是没关系,如果没有人准备就绪,我会写一个,我会发布它/ 分享它与其他人一起完成。 Thanks Rick.. No I am not referring to banker''s rounding, I am referring to VB internallousy floating point errors. VB''s ailment in its math function is caused because there are errors in theunderlying code. For example, if you do ? round (68.505,2) you get 68.5, which is incorrect; for if you round 68.505 to two decimalpoints you should get 68.51. This is caused because the underlying code that computes: ? int(68.505 * 100 + .5)/100 gives 68.5! A more serious error can be seen here: ? int(68.505 * 1000 + 5)68509 !!! (should have been 68510) So the bigger the multiplication factor of a fraction, the larger the error(the above error is a full ONE). But that''s OK, if no one have one ready, I''ll write one and I''ll post it /share it with everyone else when done. 这篇关于舍入程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-14 00:33