method
number_to_delimited
v4.1.8 -
Show latest stable
-
0 notes -
Class: NumberHelper
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0
- 3.0.9
- 3.1.0
- 3.2.1
- 3.2.8
- 3.2.13
- 4.0.2 (0)
- 4.1.8 (0)
- 4.2.1 (0)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (38)
- 5.1.7 (0)
- 5.2.3 (0)
- 6.0.0 (0)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (-37)
- 7.1.3.4 (0)
- What's this?
number_to_delimited(number, options = {})
public
Formats a number with grouped thousands using delimiter (e.g., 12,324). You can customize the format in the options hash.
Options
-
:locale - Sets the locale to be used for formatting (defaults to current locale).
-
:delimiter - Sets the thousands delimiter (defaults to “,”).
-
:separator - Sets the separator between the fractional and integer digits (defaults to “.”).
Examples
number_to_delimited(12345678) # => 12,345,678 number_to_delimited('123456') # => 123,456 number_to_delimited(12345678.05) # => 12,345,678.05 number_to_delimited(12345678, delimiter: '.') # => 12.345.678 number_to_delimited(12345678, delimiter: ',') # => 12,345,678 number_to_delimited(12345678.05, separator: ' ') # => 12,345,678 05 number_to_delimited(12345678.05, locale: :fr) # => 12 345 678,05 number_to_delimited('112a') # => 112a number_to_delimited(98765432.98, delimiter: ' ', separator: ',') # => 98 765 432,98