简体   繁体   English

MS Query中的Excel小数位

[英]Excel Decimal Places from MS Query

Here is a confusing thing in Excel - I have looked around on Stackoverflow and other sites and cannot find a solution. 这在Excel中是一件令人困惑的事情-我在Stackoverflow和其他站点上四处张望,找不到解决方案。

I extract a 3 decimal number from a text file (using VB.NET, but I don't think that is involved in the problem). 我从文本文件中提取了一个十进制数字3(使用VB.NET,但我认为问题不涉及该数字)。 I store this value as a single in and Access database - (I have tried double as well.) 我将此值存储为一个值,并存储在Access数据库中((我也尝试过两次)。

I use MS Query to bring these 3 decimal place values into Excel. 我使用MS Query将这3个小数位值带入Excel。 Although the starting text is clearly 3 decimals, in Excel there are added decimal places. 尽管起始文本显然是3个小数,但在Excel中仍添加了小数位。 For example: 例如:

Text file value: 
0.027
Stored in Access:
0.027
Value in Excel:
0.0270000007003546

I round the values to avoid confusion for others, but this can cause problems with some other programming that I do. 我将这些值四舍五入,以免引起其他人的混淆,但这会导致我执行的其他一些编程出现问题。 Any help would be appreciated. 任何帮助,将不胜感激。

I believe the problem to be related to this: 我认为问题与此有关:
http://support.microsoft.com/kb/78113 http://support.microsoft.com/kb/78113

When storing numbers, a corresponding binary number can represent every number or fractional number. 存储数字时,相应的二进制数字可以代表每个数字或小数。 For example, the fraction 1/10 can be represented in a decimal number system as 0.1. 例如,分数1/10可以在十进制系统中表示为0.1。 However, the same number in binary format becomes the repeating binary decimal 0001100110011100110011 (and so on) and can be infinitely repeated. 但是,相同的二进制格式数字将成为重复的二进制十进制0001100110011100110011(依此类推),并且可以无限重复。 This number cannot be represented in a finite (limited) amount of space. 该数字不能用有限(有限)的空间表示。 Therefore, this number is rounded down by approximately -2.8E-17 when it is stored. 因此,存储该数字时会将其四舍五入到-2.8E-17左右。

If would force Excel by setting an explicit rounding to solve the problem as both you and the documentation suggest. 如果按照您和文档的建议通过设置显式舍入来强制Excel解决该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM