Project

General

Profile

Actions

Feature #16011

closed

Digit grouping

Added by svnpenn (Steven Penny) over 5 years ago. Updated over 5 years ago.

Status:
Rejected
Target version:
-
[ruby-core:93839]

Description

Ruby seems to have no way to format a number with grouped thousands. I see Rails
has an option:

require 'active_support/all'
1234.to_s(:delimited)

However in this case it seems that grouping cannot be combined with say, leading
zeros:

https://github.com/rails/rails/issues/36707

This is quite simple with other languages, for example JavaScript:

(1234).toLocaleString(0, {minimumIntegerDigits: 7});
"0,001,234"

Python:

>>> format(1234, '08,')
'0,001,234'

Go:

package main
import "golang.org/x/text/language"
import "golang.org/x/text/message"
func main() {
   message.NewPrinter(language.English).Printf("%07d\n", 1234)
   // 0,001,234
}

Related issues 2 (1 open1 closed)

Related to Ruby master - Feature #12447: Integer#digits for extracting digits of place-value notation in any baseClosedmatz (Yukihiro Matsumoto)Actions
Related to Ruby master - Feature #18410: Proposal to make inspect include underscores on numericsOpenActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0