Apostrophe flag for printf

(Nicola Mingotti) #1

Hi guys,

There is this thing that to me seems very useful, I could try to implement it
in a first slot of available free time. But, since it is messing with "printf" I would
like to know what you do think about it.

One of the things that made me love Ruby at first sight was that i could
type long numbers as "123_332_231", with separators. (I could not in Python pre 3.6, i could in Perl AFAIR)
Typing long numbers is error prone, this is really a good lenguage feature for readability.

Ok, unfortunately still in the output phase there is not a default way to split
long numbers in output with a thousand separator.

In the standard C library of FreeBSD there is the apostrophe flag
----------- extract from $> man 3 printf -------------------------
‘'’ (apostrophe)
Decimal conversions (d, u, or i) or the integral
portion of a floating point conversion (f or F)
should be grouped and separated by thousands using
the non-monetary separator returned by



I would like to implement the apostrophe flag into Ruby printf.
Do you think it would be a valuable addition ?

I have never touched the Ruby code till now. This things seems easy
enough to be my first try;)


Dr. Nicola Mingotti
R&D - Borghi Srl
CTO - BondInsider