views:

68

answers:

2

I need to format float like price for two decimal places and thousands spaces, like this: "1 082 233.00"

+4  A: 

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.

Pär Wieslander
Thanks! It's ok!
alexandr
A: 

If you're not using Rails, take a look at: http://codesnippets.joyent.com/posts/show/1812

ropperman
Useful, thanks!
alexandr