Page 1 of 1

Formatting of complex numbers

Posted: Mon Dec 18, 2017 4:50 pm
by Leo
Hello DyalogAPL'er,
How to write Format Commands for Complex Numbers for an Output Log?

Example:
Instead of
2.500000000E000J4.330127019
should in the result list appear
2.5000J4.330
or
2.50E0J4.33E1

Many thanks in advance for your help!

Leo

Re: Formatting of complex numbers

Posted: Mon Dec 18, 2017 6:32 pm
by Roger|Dyalog
One way: format the real and imaginary parts separately, then combine. For example:

      y←2.5j4.330127019

¯3{1↓∊⍺{'J',1↓⍺⍕⍵}¨9 11○⍵}y
2.50E0J4.33E0
3{1↓∊⍺{'J',1↓⍺⍕⍵}¨9 11○⍵}y
2.500J4.330

Re: Formatting of complex numbers

Posted: Tue Dec 19, 2017 10:34 am
by Leo
Hello Roger,
thank you for the quick help!
Leo