开发者

How to format decimals

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜