如何四舍五入

发布于 2025-01-26 11:47:53 字数 705 浏览 2 评论 0原文

我认为这可能是一件容易的任务,我尝试在社区中搜索,但找不到我想要的那个,所以我有一些数字,并且想

四舍五入
431435
432之前围绕一个特定的数字。 435
433435
434435
435435
435429
436439
437437 439
438439 439
439439 439
440439

因此,如果最后一个数字在1-5之间,则IE 432将变为435;虽然437变为439。也是上面显示的示例数据,但我尝试使用MROUND或地板功能,但没有通过它来解决此问题

I assume this may be an easy task, I have tried searching in the community, but can't find the one which I am looking for, so i have some numbers and want to round to a specific number,

BEFOREAFTER ROUNDED
431435
432435
433435
434435
435435
430429
436439
437439
438439
439439
440439

So, if the last digit is between 1-5 it will be i.e. 432 becomes 435; while 437 becomes 439. Also a sample data shown above, i have tried using MROUND or FLOOR Function but not getting through it, any way to get around this

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

人生百味 2025-02-02 11:47:53

尝试:

=ARRAYFORMULA(
 IF(REGEXMATCH(INT(X9:X14)&""; ".+[1-5]$"); REGEXEXTRACT(INT(X9:X14)&""; "(.*)\d$")&5; 
 IF(REGEXMATCH(INT(X9:X14)&""; ".+[0]$"); INT(X9:X14)-1; REGEXEXTRACT(INT(X9:X14)&""; "(.*)\d$")&9))*1)

在此处输入图像描述“

try:

=ARRAYFORMULA(
 IF(REGEXMATCH(INT(X9:X14)&""; ".+[1-5]
quot;); REGEXEXTRACT(INT(X9:X14)&""; "(.*)\d
quot;)&5; 
 IF(REGEXMATCH(INT(X9:X14)&""; ".+[0]
quot;); INT(X9:X14)-1; REGEXEXTRACT(INT(X9:X14)&""; "(.*)\d
quot;)&9))*1)

enter image description here

攒一口袋星星 2025-02-02 11:47:53

好的,这有点棘手。我主要与folddown一起工作。我首先要获得一个数字,即,无论我们是6-9& 0还是1-5。

A1-ROUNDDOWN(A1,-1)

”在此处输入图像描述“

然后我移动以查找使用ifs ifs来替换它的数字以获取所有情况。

= ifs(b1 = 0,9,b1< = 5,5,a1-b1> 5,9)

之后,我在3个案例中进行了另一个ifs条款,其中<> 0,< = 5,> 5。我终于将所有内容组合到一个单线中:

= if(a1-Rounddown(a1,-1)<> 0,folddown(a1,-1)+ifs(a1-Rounddown(a1,-1) = 0,9,a1圈(a1,-1)< = 5,5,a1圈(a1,-1)> 5,9),a1-1)

希望这是可以理解的,并且有帮助。

Ok, this was a little tricky.I worked mostly with rounddown. I started by getting the ones number, i.e., whether we are 6-9&0 or 1-5.

A1-rounddown(A1,-1)

enter image description here

I then moved to find which number to replace it with using an ifs to get all the cases.

=IFS(B1=0,9,B1<=5,5,A1-B1>5,9)

Afterwards I ran another ifs clause for the 3 cases where <>0, <=5, >5. I finally combined everything into a one-liner:

=if(A1-rounddown(A1,-1)<>0,rounddown(A1,-1)+IFS(A1-rounddown(A1,-1)=0,9,A1-rounddown(A1,-1)<=5,5,A1-rounddown(A1,-1)>5,9),A1-1)

Hopefully this was understandable and helpful.

稀香 2025-02-02 11:47:53
  • 如果
  • (数字-1)mod 10&gt; 4(IE 6,7,8,9),减去1
  • 否则要获得9
=ArrayFormula(CEILING(A:A/5)*5-(MOD(A:A-1,10)>4))
  • Round to nearest 5
  • If (number - 1) mod 10 > 4 (i.e. 6, 7, 8, 9), subtract 1 to get 9
  • Otherwise, leave it alone to not round
=ArrayFormula(CEILING(A:A/5)*5-(MOD(A:A-1,10)>4))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文