Formats a number with grouped thousands using delimiter
(e.g., 12,324). You can customize the format in the options hash.
Options
- :delimiter - Sets the thousands delimiter (defaults to
",").
- :separator - Sets the separator between the units (defaults to
".").
Examples
number_with_delimiter(12345678) # => 12,345,678
number_with_delimiter(12345678.05) # => 12,345,678.05
number_with_delimiter(12345678, :delimiter => ".") # => 12.345.678
number_with_delimiter(12345678, :seperator => ",") # => 12,345,678
number_with_delimiter(98765432.98, :delimiter => " ", :separator => ",")
# => 98 765 432,98
You can still use number_with_delimiter with the
old API that accepts the delimiter as its optional second and the
separator as its optional third parameter:
number_with_delimiter(12345678, " ") # => 12 345.678
number_with_delimiter(12345678.05, ".", ",") # => 12.345.678,05