如何将整数自动转换为小数点后两位? [英] How to auto-convert a whole number into it's 2 decimals points?

查看:65
本文介绍了如何将整数自动转换为小数点后两位?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按照之前的答案

Following the previous answers How to make a condition based on the number of decimals a number has with the IFS and AND functions in Google Sheets?

The formula given didn't return a result for whole numbers (any number without decimals, for example: 1(.00), 12(.00) etc.).

To make it return a result also for inputs with whole numbers, I thought of some formula like this:

=IF(A1=(a whole number/number without decimals),A1.00(A1 formatted as a whole number with two decimals),A1(A1 with any number of decimals>2 decimals).

How to make this formula

=ARRAYFORMULA(
 IF((LEN(IFERROR(REGEXEXTRACT(TO_TEXT(A1:A), "\.(.*)")))=4) * 
    (A1:A>B1:B) * (C1:C="Good"),     (A1:A-B1:B)*10000,
 IF((LEN(IFERROR(REGEXEXTRACT(TO_TEXT(A1:A), "\.(.*)")))=2) * 
    (A1:A>B1:B) * (C1:C="Great"),    (A1:A-B1:B)*100, )))

valid for whole numbers as well?

So that it returns a result for the whole number as well?

解决方案

=ARRAYFORMULA(
 IF((LEN(IFERROR(REGEXEXTRACT(TO_TEXT(A1:A), "\.(.*)")))=4) * 
    (A1:A>B1:B) * (C1:C="Good"),     (A1:A-B1:B)*10000,
 IF((LEN(IFERROR(REGEXEXTRACT(TO_TEXT(TEXT(A1:A, "00.00")), "\.(.*)")))=2) * 
    (A1:A>B1:B) * (C1:C="Great"),    (A1:A-B1:B)*100, )))

这篇关于如何将整数自动转换为小数点后两位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆