This topic has been archived. It cannot be replied.
-
工作学习 / 学科技术讨论 / 急问一个excel的问题。用TRUNC公式取整数,为何在同一个表里,有的数取的对,有的数会比正确值少1?折腾半天,死活找不出原因,请高手相助。谢谢先。
-neversaydie(乐乐);
2010-9-16
(#6278895@0)
-
Can you give some example?
-xiaofeiyang(小肥羊);
2010-9-16
(#6279008@0)
-
不是高手,我想是因为前面的数因为4舍5如,有一定的误差,再误差上再作别的运算,会把误差放大。
-baishan(baishan);
2010-9-16
(#6279058@0)
-
That's very normal. In Excel many integer is stored not as it appear. For example 1 could be 0.999999999999999999999.
-jeffrey815(Smartiecat);
2010-9-16
(#6279066@0)
-
TRUNC only removes the fractional part of the number. This function does not round. If you want to round you can use ROUND or INT
-xiaofeiyang(小肥羊);
2010-9-16
(#6279360@0)
-
谢谢各位回答。我做的是两个日期时间之间的差额,要用天,时,分表示出来。比如2010/9/1 3:00和2010/9/3 13:00之间差几天几小时几分。我想用TRUNC取两个值之间的差,就是天数,这个没问题。但用TRUNC取剩余天数乘以24以后的整数做小时数的时候就出现了开始我提的问题。
-neversaydie(乐乐);
2010-9-16
(#6279460@0)
-
Truncate属rounding的一种,有时定义不同。对你比较实用的方法是:两个日期相减之前,先判断一下大小,不要出现负值。
-perryuan(perryuan);
2010-10-10
(#6314797@0)
-
你把你的公式写出来,让大家看看嘛。不会看到下面雷人的代码吧
-manniangpai(慢两拍);
2010-10-11
(#6315648@0)
-
following formula will do the job, but cells A1 and A2 need to be formated as date type like 3/14/01 13:30:
=INT(A2-A1) & " Days, " & TEXT(MOD(A2-A1,1), "h"" Hrs, ""m"" Min,
""s"" Sec""")
-frank8s(frank);
2010-10-13
(#6317967@0)
-
.=CONCATENATE(DAY(B1-A1),"天",HOUR(B1-A1),"时",MINUTE(B1-A1),"分",SECOND(B1-A1),"秒")
-kingsw(Steven);
2010-10-13
{92}
(#6318009@0)