| Bill Allombert on Sun, 07 Jan 2024 23:32:38 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: printf "%'d" missing in Pari/GP for printing 1000s commas |
On Sun, Jan 07, 2024 at 05:42:38PM +0100, hermann@stamm-wilbrandt.de wrote:
> In C
>
> setlocale(LC_NUMERIC, "");
> printf("%'d\n", 1123456789);
>
> outputs:
>
> 1,123,456,789
Note that this is not part of C99.
> Is there a more general solution?
You can do:
f(n)=my(V=strsplit(Str(n)));forstep(i=#V-3,1,-3,V[i]=concat(V[i],","));concat(V)
Cheers,
Bill