Symbol Format

From NARS2000
Jump to navigationJump to search

⍕ — (Format numbers and dates Function/Symbol) — Keystroke ALT+' — Character 9046

Usage

Examples

Monadic Examples - Convert Numbers to Strings/Character vectors:

      A←⎕TS   ⍝assign the current Time Stamp to variable A
      A       ⍝display A's value
2015 2 25 16 21 52 128     ⍝ Yr Mo Day Hr(24 hr clock) Min Sec Millisecs
      ⍴A      ⍝date-time stamp vector has 7 elements
7
      ⍕A      ⍝monadic format A (converts A from 7 element numeric vector into a 22 character string
2015 2 25 16 21 52 128
      ⍴⍕A
22

      B←32.10958 0 ¯101.4914     ⍝variable B is assigned 3 numbers
      ⍴B
3
      B
32.10958 0 ¯101.4914
      ⍕B                        ⍝format B converts the 3 numbers into a 20-character string
32.10958 0 ¯101.4914
      ⍴⍕B
20

Dyadic Example - Convert Numbers to Strings(with column width/reserved # spaces AND rounding to # decimal places):

      C←2 3⍴ 32.10958 0 ¯101.4914 ¯99.40878 ¯101.872 1001.48173       ⍝variable C is assigned 2x3 matrix of 6 numbers
      C                        ⍝show the contents of C (2 rows by 3 cols of positive and negative numbers)
 32.10958    0     ¯101.4914 
¯99.40878 ¯101.872 1001.48173
      ⍴C
2 3

      12 2⍕C    ⍝Dyadic format converts the 6 numbers in C - into a 2 rows by 36 cols character matrix  (12=col width, 2=round to 2 decimal places)
       32.11        0.00     ¯101.49
      ¯99.41     ¯101.87     1001.48
      ⍴(12 2⍕C)
2 36

See Also

For more powerful number formatting, see ⎕FMT or Quad FMT

(particularly ⎕FMT dyadic calls)


NARS 2000 Lang
Tool
Bar
+ - × ÷ * ! ? |
< = >
~ § π .. ,
/ \ ¨ .
_ ¯
Second Row i j k i j k l g p r v x