actually ⎕FIO emulates printf() rather than calling it. There were a number of
nasty effects caused by locales when using printf() and friends and therefore I
decided to implement it explicitly. For that reason not all format flags are supported.
I will look into adding support for the thousands separator (but not supporting the
locales nonsense). That is, the thousands separator will always be comma and not
e.g. full-stop like in some countries and comma in others.
BTW format by example should have done the job (see the APL2 language
reference page 140):
"5,555.50" ⍕ 1234.56
1,234.56
Best Regards,
Jürgen
On 7/4/22 12:56 PM, Martin Michel
wrote:
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