在excel vba中,A = .20& B = .40,B-A给我这个结果0.2000000029809232。为什么?变速器被声明为Single [英] In excel vba with A =.20 & B = .40, B-A give me this result0.2000000029809232. WHY? The varaibles are declared as Single

查看:96
本文介绍了在excel vba中,A = .20& B = .40,B-A给我这个结果0.2000000029809232。为什么?变速器被声明为Single的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个变量的问题,即使是数组,其中数组包含带有两位小数的数字(例如:2.30)&如果加上或减去另一个带有两个小数的a,得到相同类型的结果&当然,条件不再工作
因为变量不再相等?

I have this problem with several variables even with array where the array contain number with two decimal(ex: 2.30) & if add or subtract from another with two decimal a get the same kind of result & of course the conditionnal don't work anymore because the variable are not anymore equal?

我使用excel 2010,我不记得excel 2007有这个问题。

I use excel 2010, I don't remember to have this problem with excel 2007.

谢谢你的帮助

Jean

推荐答案

<你应该在所有版本的VBA中遇到这个问题。单精度数字不够准确,无法保持所需的结果。将变量类型更改为double并且一切都应该很好

Hi, you should get this problem in all versions of VBA. Single precision numbers are not accurate enough to keep the results you require. Change you variable type to double and all should be well

 

问候

 

ADG


这篇关于在excel vba中,A = .20&amp; B = .40,B-A给我这个结果0.2000000029809232。为什么?变速器被声明为Single的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆