admin管理员组文章数量:1405308
I'm trying to ensure excel rounds to 2 decimal decimal points after looking at the entire number. Currently if I do this
=round(6.2445,2)
its gives me 6.24
. However it should actually give me 6.25
.
I know one workaround would be doing =round(round(6.2445,3),2)
, but that won't work for 6.24445
.
I can't use roundup
as that would be incorrect while rounding 6.24145
I'm trying to ensure excel rounds to 2 decimal decimal points after looking at the entire number. Currently if I do this
=round(6.2445,2)
its gives me 6.24
. However it should actually give me 6.25
.
I know one workaround would be doing =round(round(6.2445,3),2)
, but that won't work for 6.24445
.
I can't use roundup
as that would be incorrect while rounding 6.24145
1 Answer
Reset to default 5Rounding rules in mathematics generally apply when on the "border". Everything above the border gets rounded up, and below the border gets rounded down.
What happens in the borderline condition can vary: round up; round away from zero; round to the nearest even number; and a few other more esoteric methods.
In your example, you are not really rounding to two decimals. Since 6.2445
is less than 6.25
, it should properly round to 6.24
.
What you are asking for is rather to sequentially round the number starting at the penultimate digit and working your way back until you have two digits left.
The formula in my comment will do that sequential rounding. More generally written:
=REDUCE(A1,SEQUENCE(n,,n+(number_of_digits_minus_one),-1),LAMBDA(a,b,ROUND(a,b)))
- A1: Number to be sequentially rounded
- n: Maximum number of digits to account for in the decimal portion of
A1
. No need for this to be greater than15
, but it can be greater than the number of digits in your actual number.
Note that this is an extended version of your workaround =round(round(6.2445,3),2)
本文标签: Excel rounding to look at all decimal pointsStack Overflow
版权声明:本文标题:Excel rounding to look at all decimal points - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744301244a2599592.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
REDUCE(A1,SEQUENCE(10,,11,-1),LAMBDA(a,b,ROUND(a,b)))
– Ron Rosenfeld Commented Mar 23 at 0:14=REDUCE(A1,SEQUENCE(LEN(A1),,,LEN(A1)+1,-1),LAMBDA(a,b,ROUND(a,b)))
– P.b Commented Mar 23 at 20:19n=15
or16
or whatever the largest number of digits the OP thinks might be of significance. – Ron Rosenfeld Commented Mar 24 at 0:00