From: shyouhei@... Date: 2019-07-19T07:07:15+00:00 Subject: [ruby-core:93844] [Ruby master Feature#16011] Digit grouping Issue #16011 has been updated by shyouhei (Shyouhei Urabe). znz (Kazuhiro NISHIYAMA) wrote: > Some `printf` can use `%'d`. Yes but that's not what the OP wants. ``` % printf "%'07d\\n" 1234 001,234 ``` The output is different. ---------------------------------------- Feature #16011: Digit grouping https://bugs.ruby-lang.org/issues/16011#change-79728 * Author: svnpenn (Steven Penny) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- 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 } -- https://bugs.ruby-lang.org/ Unsubscribe: