我正在将一个从VB6移植到C#的应用程序.我发现一个特别是导致我出现问题的计算.它基本归结为
opperandA *.01 / opperandB
Run Code Online (Sandbox Code Playgroud)
我的具体例子是:
1 * .01 / 12
Run Code Online (Sandbox Code Playgroud)
在VB6(和Windows计算器)中,我得到8.3333333333e-4.
但是,在C#(和其他所有计算器)中,我得到.00083333.
第二个数字对我来说很有意义,但我必须复制第一个结果并且我想了解它,那么为什么VB6和Windows计算器会产生奇怪的结果呢?
小智 5
8.3333333333e-4与0.00083333相同.它等同于:
8.3333333333 * 10^-4
= 8.3333333333 times ( ten to the power of -4 )
= 8.3333333333 * 0.0001
= 0.00083333333
N.b. After rounding
Run Code Online (Sandbox Code Playgroud)
e代表指数,相关的维基百科文章是http://en.wikipedia.org/wiki/Exponentiation
| 归档时间: |
|
| 查看次数: |
86 次 |
| 最近记录: |