开发者

How to format decimals

开发者 https://www.devze.com 2023-01-16 06:43 出处:网络
I need to format float like price for two decimal places and t开发者_JAVA百科housands spaces, like this:

I need to format float like price for two decimal places and t开发者_JAVA百科housands spaces, like this: "1 082 233.00"


Use number_to_currency or number_with_precision:

number_with_precision(1082233, :precision => 2,
                               :separator => '.',
                               :delimiter => ' ')
# => '1 082 233.00'

See the NumberHelper documentation for details.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号