I have the following number in APL
1200000002341
When I do the following
k←1200000002341
k←⍕k
The value of k becomes 1.2E12.
How do I preserve the intricacies of the number when converting to character form?
I have the following number in APL
1200000002341
When I do the following
k←1200000002341
k←⍕k
The value of k becomes 1.2E12.
How do I preserve the intricacies of the number when converting to character form?
It may depend on the exact APL implementation you are using. In Dyalog APL, the system variable ⎕PP
controls the precision. From the docs:
⎕PP
is the number of significant digits in the display of numeric output.⎕PP
may be assigned any integer value in the range 1 to 34.
For double-precision floating-point numbers (which is often the default for large numbers), the value of 17 is commonly used (which is enough to represent a double without precision loss).
⍕1200000002341
1.200000002E12
⎕PP←17
⍕1200000002341
1200000002341
Another way would be to convert the given number to an array of digits in base 10, and then convert each digit into string:
∊⍕¨10⊥⍣¯1⊢1200000002341
1200000002341
Read the code above as
10⊥⍣¯1
Convert to decimal digits⍕¨
Stringify (convert number to string) each digit∊
Enlist; flatten all (nested) items into a single vectorYou don't say which dialect of APL you're using. Here's a simple (and perhaps hacky) way of doing it that should work on most:
k←1200000002341
n←⌈10⍟k+1 ⍝ number of digits in k
s←⍕(n⍴10)⊤k ⍝ string
s←s~' ' ⍝ remove blanks