Count number of decimal places in a Float (or Decimal) in Swift

后端 未结 5 1603
长情又很酷
长情又很酷 2021-02-06 05:43

I want to count the number of decimal places (ignoring trailing zeros) in a Float (or NSDecimalNumber) for example:

1.45000 => 2
5.98 => 2
1.00 => 0
0.8         


        
5条回答
提交回复
热议问题