⍝ ⍺-ary representation of rational ⍵:

    10ary 4÷7 
0.571428571428...

    16ary 3÷13
0.3B13B1...

    2ary 3÷7 
0.011011...

    3ary 2*¯4
0.00120012...

    10ary 3*¯3
0.037037...

    10ary ○1 
3.1415926535898?

    16ary ○1 
3.243F6A8885A?

⍝ tricky cases:

    10ary 666.6
666.6

    10ary 1234.6
1234.6

    10ary 1e¯2×9+10÷11
0.099090...

⍝ more ...

    369+1÷7                 ⍝ system formatted
369.1428571

    10ary 369+1÷7           ⍝ ⍺-ary formatted
369.142857142857...

    disp ¯10ary 369+1÷7     ⍝ ⍺-ary unformatted
┌─┬─┬─────┬───────────┬─┐
│1│3│3 6 9│1 4 2 8 5 7│1│
└─┴─┴─────┴───────────┴─┘

    ↑10ary¨(10*¯4+⍳9)÷7     ⍝ check exp-rotation of rep field.
0.000142857142857... 
0.00142857142857...  
0.0142857142857...   
0.142857142857...    
1.428571428571...    
14.285714285714...   
142.857142857142...  
1428.571428571428... 
14285.714285714285...

    disp ¯2ary ÷141         ⍝ longish rep sequence.
┌─┬──┬┬───────────────────────────────────────────────────────────────────────────────────────────┬─┐
│1│¯7││1 1 1 0 1 0 0 0 0 1 1 0 0 1 0 1 1 0 1 0 1 1 0 0 0 1 1 1 1 0 1 1 0 1 1 1 0 1 1 0 0 0 0 0 0 0│1│
└─┴──┴┴───────────────────────────────────────────────────────────────────────────────────────────┴─┘

    ⍕ 10ary¨ ÷/¨⍳10 10      ⍝ decimal (10-ary) table
 1   0.5  0.33...  0.25  0.2  0.166...  0.142857142857...  0.125  0.11...  0.1 
 2   1    0.66...  0.5   0.4  0.33...   0.285714285714...  0.25   0.22...  0.2 
 3   1.5  1        0.75  0.6  0.5       0.428571428571...  0.375  0.33...  0.3 
 4   2    1.33...  1     0.8  0.66...   0.571428571428...  0.5    0.44...  0.4 
 5   2.5  1.66...  1.25  1    0.833...  0.714285714285...  0.625  0.55...  0.5 
 6   3    2        1.5   1.2  1         0.857142857142...  0.75   0.66...  0.6 
 7   3.5  2.33...  1.75  1.4  1.166...  1                  0.875  0.77...  0.7 
 8   4    2.66...  2     1.6  1.33...   1.142857142857...  1      0.88...  0.8 
 9   4.5  3        2.25  1.8  1.5       1.285714285714...  1.125  1        0.9 
 10  5    3.33...  2.5   2    1.66...   1.428571428571...  1.25   1.11...  1   

    ⍕ 2ary¨ ÷/¨⍳10 8        ⍝ binary table
 1     0.1    0.0101...   0.01   0.00110011...  0.00101...  0.001001...  0.001 
 10    1      0.1010...   0.1    0.01100110...  0.0101...   0.010010...  0.01  
 11    1.1    1           0.11   0.10011001...  0.1         0.011011...  0.011 
 100   10     1.0101...   1      0.11001100...  0.1010...   0.100100...  0.1   
 101   10.1   1.1010...   1.01   1              0.11010...  0.101101...  0.101 
 110   11     10          1.1    1.00110011...  1           0.110110...  0.11  
 111   11.1   10.0101...  1.11   1.01100110...  1.00101...  1            0.111 
 1000  100    10.1010...  10     1.10011001...  1.0101...   1.001001...  1     
 1001  100.1  11          10.01  1.11001100...  1.1         1.010010...  1.001 
 1010  101    11.0101...  10.1   10             1.1010...   1.011011...  1.01  

    ⍕ 3ary¨ ÷/¨⍳10 7        ⍝ ternary table
 1    0.11...   0.1   0.0202...  0.01210121...  0.011...  0.010212010212... 
 2    1         0.2   0.11...    0.10121012...  0.1       0.021201021201... 
 10   1.11...   1     0.2020...  0.12101210...  0.11...   0.102120102120... 
 11   2         1.1   1          0.21012101...  0.2       0.120102120102... 
 12   2.11...   1.2   1.0202...  1              0.211...  0.201021201021... 
 20   10        2     1.11...    1.01210121...  1         0.212010212010... 
 21   10.11...  2.1   1.2020...  1.10121012...  1.011...  1                 
 22   11        2.2   2          1.12101210...  1.1       1.010212010212... 
 100  11.11...  10    2.0202...  1.21012101...  1.11...   1.021201021201... 
 101  12        10.1  2.11...    2              1.2       1.102120102120... 

    ⍕ 16ary¨ ÷/¨⍳10 9           ⍝ hexadecimal table
 1  0.8  0.55...  0.4  0.33...  0.2AA...  0.249249...  0.2  0.1C71C7... 
 2  1    0.AA...  0.8  0.66...  0.55...   0.492492...  0.4  0.38E38E... 
 3  1.8  1        0.C  0.99...  0.8       0.6DB6DB...  0.6  0.55...     
 4  2    1.55...  1    0.CC...  0.AA...   0.924924...  0.8  0.71C71C... 
 5  2.8  1.AA...  1.4  1        0.D55...  0.B6DB6D...  0.A  0.8E38E3... 
 6  3    2        1.8  1.33...  1         0.DB6DB6...  0.C  0.AA...     
 7  3.8  2.55...  1.C  1.66...  1.2AA...  1            0.E  0.C71C71... 
 8  4    2.AA...  2    1.99...  1.55...   1.249249...  1    0.E38E38... 
 9  4.8  3        2.4  1.CC...  1.8       1.492492...  1.2  1           
 A  5    3.55...  2.8  2        1.AA...   1.6DB6DB...  1.4  1.1C71C7... 

    ⍕ 20ary¨ ÷/¨⍳10 9       ⍝ vigesimal (20-ary) table
 1  0.A  0.6D6D...  0.5  0.4  0.36D6D...  0.2H2H...  0.2A  0.248HFB248HFB... 
 2  1    0.D6D6...  0.A  0.8  0.6D6D...   0.5E5E...  0.5   0.48HFB248HFB2... 
 3  1.A  1          0.F  0.C  0.A         0.8B8B...  0.7A  0.6D6D...         
 4  2    1.6D6D...  1    0.G  0.D6D6...   0.B8B8...  0.A   0.8HFB248HFB24... 
 5  2.A  1.D6D6...  1.5  1    0.GD6D6...  0.E5E5...  0.CA  0.B248HFB248HF... 
 6  3    2          1.A  1.4  1           0.H2H2...  0.F   0.D6D6...         
 7  3.A  2.6D6D...  1.F  1.8  1.36D6D...  1          0.HA  0.FB248HFB248H... 
 8  4    2.D6D6...  2    1.C  1.6D6D...   1.2H2H...  1     0.HFB248HFB248... 
 9  4.A  3          2.5  1.G  1.A         1.5E5E...  1.2A  1                 
 A  5    3.6D6D...  2.A  2    1.D6D6...   1.8B8B...  1.5   1.248HFB248HFB... 

    ⎕ct←1e¯14
    36ary 55        ⍝ Quario/Garue test case:
1J
    ⎕ct←1e¯15
    36ary 55
1J
    ⎕ct←1e¯16

:If ⎕FR=645
        36ary 55
    1I.ZZZZZZZZZ?
:Else                                                                   ⍝ <V>1287
:EndIf

Back to: code

Back to: Workspaces