⍝ Phinary representation of numbers ⍵: phinary 42 ⍝ phinary number. 10100010.00100001 align←⌽∘↑⍨∘(-∘(⌈/)⍨∘('.'∘(⍳¨⍨)))⍨ ⍝ align '.'s in char matrix. 2 80 cols ⍕ ,∘align∘phinary⍨ ¯4 to 100 ¯4 ¯101.01 31 10000010.00101001 66 101000001.00000101 ¯3 ¯100.01 32 10000100.00101001 67 101000010.01000101 ¯2 ¯10.01 33 10000101.00101001 68 101000100.01000101 ¯1 ¯1 34 10001000.10001001 69 101000101.01000101 0 0 35 10001010.00001001 70 101001000.10010101 1 1 36 10010000.00001001 71 101001010.00010101 2 10.01 37 10010001.00001001 72 101010000.00010101 3 100.01 38 10010010.01001001 73 101010001.00010101 4 101.01 39 10010100.01001001 74 101010010.01010101 5 1000.1001 40 10010101.01001001 75 101010100.01010101 6 1010.0001 41 10100000.10100001 76 101010101.01010101 7 10000.0001 42 10100010.00100001 77 1000000000.1010101001 8 10001.0001 43 10100100.00100001 78 1000000010.0010101001 9 10010.0101 44 10100101.00100001 79 1000000100.0010101001 10 10100.0101 45 10101000.10000001 80 1000000101.0010101001 11 10101.0101 46 10101010.00000001 81 1000001000.1000101001 12 100000.101001 47 100000000.00000001 82 1000001010.0000101001 13 100010.001001 48 100000001.00000001 83 1000010000.0000101001 14 100100.001001 49 100000010.01000001 84 1000010001.0000101001 15 100101.001001 50 100000100.01000001 85 1000010010.0100101001 16 101000.100001 51 100000101.01000001 86 1000010100.0100101001 17 101010.000001 52 100001000.10010001 87 1000010101.0100101001 18 1000000.000001 53 100001010.00010001 88 1000100000.1010001001 19 1000001.000001 54 100010000.00010001 89 1000100010.0010001001 20 1000010.010001 55 100010001.00010001 90 1000100100.0010001001 21 1000100.010001 56 100010010.01010001 91 1000100101.0010001001 22 1000101.010001 57 100010100.01010001 92 1000101000.1000001001 23 1001000.100101 58 100010101.01010001 93 1000101010.0000001001 24 1001010.000101 59 100100000.10100101 94 1001000000.0000001001 25 1010000.000101 60 100100010.00100101 95 1001000001.0000001001 26 1010001.000101 61 100100100.00100101 96 1001000010.0100001001 27 1010010.010101 62 100100101.00100101 97 1001000100.0100001001 28 1010100.010101 63 100101000.10000101 98 1001000101.0100001001 29 1010101.010101 64 100101010.00000101 99 1001001000.1001001001 30 10000000.10101001 65 101000000.00000101 100 1001001010.0001001001 ⎕DCT DCT ← ⎕CT ⎕DCT align phinary 10*0 to 7 ⍝ powers of 10 1 10100.0101 1001001010.0001001001 100010010001000.10001001010001 10000010010000010000.00010000001000101001 101010001010100000100000.101000101000000010000001 10100000100010010000100010001.0001000010100101000100000101 1001000010101000001010001001010101.0101001000100000101000000100001 ⎕DCT ← DCT Ø ← (1+5*÷2)÷2 ⍝ golden mean. align phinary Ø* 0 to 10 ⍝ phinary non-negative powers of phi. 1 10 100 1000 10000 100000 1000000 10000000 100000000 1000000000 10000000000 align phinary Ø* ¯1 to ¯10 ⍝ phinary negative powers of phi. 0.1 0.01 0.001 0.0001 0.00001 0.000001 0.0000001 0.00000001 0.000000001 0.0000000001 ↑{(⍕⍵),': ',⍕0 phinary ⍵}¨ 0 to 9 ⍝ unformatted raw powers. 0: 1: 0 2: 1 ¯2 3: 2 ¯2 4: 2 0 ¯2 5: 3 ¯1 ¯4 6: 3 1 ¯4 7: 4 ¯4 8: 4 0 ¯4 9: 4 1 ¯2 ¯4 align phinary (5*÷2)* 0 to 8 ⍝ powers of sqrt(5). 1 10.1 1000.1001 100000.00001 1010000.000101 100010010.010001001 10000000010.0100000001 101000001000.00100000101 10001001010100.01010010001001 phinary⍣2 ,¯2 to 10 ⍝ round-trip to check inverse. ¯2 ¯1 0 1 2 3 4 5 6 7 8 9 10 ⍕↑{⍺ ⍵}∘(phinary⍣2)⍨ ,\9/'1' ⍝ canonical from non-canonical form 1 11 111 1111 11111 111111 1111111 11111111 111111111 1 100 1001 10100 101001 1010100 10101001 101010100 1010101001 ⍝∇ phinary to cols Back to: code Back to: Workspaces