bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

printf issue with thousands separator


From: Martin Michel
Subject: printf issue with thousands separator
Date: Mon, 4 Jul 2022 12:56:31 +0200
User-agent: NeoMutt/20170113 (1.7.2)

Hi there,

I want to print a table which also includes some financal figures. Here
I need to group with a thousands separator. My first attempts using the
"Format by example" method failed due to limitations of it. That's why I
fell back to the ⎕FIO system interface, trying the same with `printf`.

However, now I see that using it from the APL interpreter leads to
different results than eg. coreutils printf. I was thinking it uses the
same C library function under the hood (GNU glibc?).

So here is the example, first what I got from coreutils (and what I want
to get):

    printf "$ %+'.0f    $ %+'.0f\n" 1234523.435 -9587294.01
$ +1,234,523    $ -9,587,294

And here is APL's output, ignoring the thousands:
    "$ %+'.0f    $ %+'.0f\n" 1234523.435 ¯9587294.01 ⎕FIO[22] 1
$ +1234523    $ -9587294

Is there a way to "activate" the thousands separator (%') in APL?
Alternatively, is it possible after all to achieve my desired output
with APL "format by example" or other means (I may have missed something
but having two decorators with negative numbers and without decimal
points seems impossible).

Any help is welcome, thanks for it in advance!

Kind regards,
Martin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]