⍝ (big-endian) hex display of float array:

:If ⎕FR=1287            ⍝ decimal floating point

    :ReturnIf 'AIX'≡3↑⊃'.'⎕wg'APLVersion'       ⍝ avoid differences on p6 p7
    :If '2208'≡4↑hexf 1                         ⍝ DPD

            hexf ¯1 0 1
        A2080000000000000000000000000001 22080000000000000000000000000000 22080000000000000000000000000001

            hexf ¯1 1∘.×↑{÷⍵}\2/⊂2 3⍴⍳6
        A2080000000000000000000000000001 A2080000000000000000000000000002 A2080000000000000000000000000003
        A2080000000000000000000000000004 A2080000000000000000000000000005 A2080000000000000000000000000006
                                                                                                          
        A2080000000000000000000000000001 A207C000000000000000000000000005 ADFF9B36CDB36CDB36CDB36CDB36CDB3
        A2078000000000000000000000000025 A207C000000000000000000000000002 A5FFB66D9B66D9B66D9B66D9B66D9B67
                                                                                                          
                                                                                                          
        22080000000000000000000000000001 22080000000000000000000000000002 22080000000000000000000000000003
        22080000000000000000000000000004 22080000000000000000000000000005 22080000000000000000000000000006
                                                                                                          
        22080000000000000000000000000001 2207C000000000000000000000000005 2DFF9B36CDB36CDB36CDB36CDB36CDB3
        22078000000000000000000000000025 2207C000000000000000000000000002 25FFB66D9B66D9B66D9B66D9B66D9B67

            rtrip←≡∘(hexf⍣2)⍨                   ⍝ check round-trip.

            rtrip ¯1 1∘.×↑{÷⍵}\2/⊂2 3⍴⍳6        ⍝ high-rank
        1
            rtrip ⍳¨⍳2/2                        ⍝ high-depth
        1
            hexf ¯1 1∘.×↑{÷⍵}\2/⊂(⌊/⍬)(⌈/⍬)     ⍝ -/+ infinite and infinitesimal.
        F7FFCFF3FCFF3FCFF3FCFF3FCFF3FCFF 77FFCFF3FCFF3FCFF3FCFF3FCFF3FCFF
        80000100000000000000000000000000 00000100000000000000000000000000
                                                                         
        77FFCFF3FCFF3FCFF3FCFF3FCFF3FCFF F7FFCFF3FCFF3FCFF3FCFF3FCFF3FCFF
        00000100000000000000000000000000 80000100000000000000000000000000

            hexf (2*¯1022)÷2*4×⍪ 0 to 14        ⍝ denormal numbers.
        29B2D251CE3EA1D016AC1A4CB976CA05
        25B299ADC4E1B9C009B23176E486CBD3
        69B231BD6BD9EEFD580B7A486D21E787
        35B1E32625241F47B29B4B2E2701271D
        2DB19DB2ED65B1235E10F8446C3E2CB6
        29B14A1A7F9ABB572654916A9145B510
        25B11A651DE974D5B3EACCC4E0E53E86
        69B094F118589605A2398DCF3F60BE13
        35B048AD4FEAAD98978C64C7E8FA150F
        2DB01372BB16B2CBB7469DB8540334F7
        29AFC23CEA0F797C5933CD497F5B3936
        25AF9640B85374E9B34C3A05889F0B47
        3DAF28D141B3966CCE1A2D2034B07EC5
        31AECCCD5A5884A65907E5DADAECA916
        2DAE86B2716AA1F9A23483B52DD899CB

    :Else                                       ⍝ BID
            hexf ¯1 0 1
        B0400000000000000000000000000001 30400000000000000000000000000000 30400000000000000000000000000001

            hexf ¯1 1∘.×↑{÷⍵}\2/⊂2 3⍴⍳6
        B0400000000000000000000000000001 B0400000000000000000000000000002 B0400000000000000000000000000003
        B0400000000000000000000000000004 B0400000000000000000000000000005 B0400000000000000000000000000006
                                                                                                          
        B0400000000000000000000000000001 B03E0000000000000000000000000005 AFFCA45894E4829567D9DA2155555555
        B03C0000000000000000000000000019 B03E0000000000000000000000000002 AFFC522C4A72414AB3ECED10AAAAAAAB


        30400000000000000000000000000001 30400000000000000000000000000002 30400000000000000000000000000003
        30400000000000000000000000000004 30400000000000000000000000000005 30400000000000000000000000000006

        30400000000000000000000000000001 303E0000000000000000000000000005 2FFCA45894E4829567D9DA2155555555
        303C0000000000000000000000000019 303E0000000000000000000000000002 2FFC522C4A72414AB3ECED10AAAAAAAB

            rtrip←≡∘(hexf⍣2)⍨                   ⍝ check round-trip.

            rtrip ¯1 1∘.×↑{÷⍵}\2/⊂2 3⍴⍳6        ⍝ high-rank
        1
            rtrip ⍳¨⍳2/2                        ⍝ high-depth
        1
            hexf ¯1 1∘.×↑{÷⍵}\2/⊂(⌊/⍬)(⌈/⍬)     ⍝ -/+ infinite and infinitesimal.
        DFFFED09BEAD87C0378D8E63FFFFFFFF 5FFFED09BEAD87C0378D8E63FFFFFFFF
        8000007E37BE2022C0914B2680000000 0000007E37BE2022C0914B2680000000

        5FFFED09BEAD87C0378D8E63FFFFFFFF DFFFED09BEAD87C0378D8E63FFFFFFFF
        0000007E37BE2022C0914B2680000000 8000007E37BE2022C0914B2680000000
                                                                 
            hexf (2*¯1022)÷2*4×⍪ 0 to 14        ⍝ denormal numbers.
        2D966DB4616541769502D339CC6DCFB5
        2D944490BCDF48EA1D21C4041FC4A1D1
        2D91AC889C7387B736130919C68CF35B
        2D8F0BD561C834D281CBE5B01C181819
        2D8CA7655D1D2103911F6F8E118F0F10
        2D8A689F5A3234A23AB3A5B8CAF9696A
        2D884163985F60E564B047937EDBE1E2
        2D8598AE78541D99B54DBF59D8DE43C5
        2D82FF6D0B34928011509798278AEA5B
        2D809FA42700DB900AD25EBF18B6D279
        2D7E63C69860893A06C37B376F72438C
        2D7C3E5C1F3C55C4443A2D02A5A76A37
        2D7985BFC339180AAA6B99508B5657D9
        2D76F397DA03AF06AA833FD25715F6E8
        2D74983EE8424D642A9207E3766DBA51

    :EndIf

:Else
        hexf ¯1 0 1
    BFF0000000000000 0000000000000000 3FF0000000000000

        hexf ¯1 1∘.×↑{÷⍵}\2/⊂2 3⍴⍳6
    BFF0000000000000 C000000000000000 C008000000000000
    C010000000000000 C014000000000000 C018000000000000
                                                      
    BFF0000000000000 BFE0000000000000 BFD5555555555555
    BFD0000000000000 BFC999999999999A BFC5555555555555
                                                      
                                                      
    3FF0000000000000 4000000000000000 4008000000000000
    4010000000000000 4014000000000000 4018000000000000
                                                      
    3FF0000000000000 3FE0000000000000 3FD5555555555555
    3FD0000000000000 3FC999999999999A 3FC5555555555555

        rtrip←≡∘(hexf⍣2)⍨                   ⍝ check round-trip.

        rtrip ¯1 1∘.×↑{÷⍵}\2/⊂2 3⍴⍳6        ⍝ high-rank
    1
        rtrip ⍳¨⍳2/2                        ⍝ high-depth
    1
        hexf ¯1 1∘.×↑{÷⍵}\2/⊂(⌊/⍬)(⌈/⍬)     ⍝ -/+ infinite and infinitesimal.
    FFEFFFFFFFFFFFFF 7FEFFFFFFFFFFFFF
    8004000000000000 0004000000000000
                                     
    7FEFFFFFFFFFFFFF FFEFFFFFFFFFFFFF
    0004000000000000 8004000000000000

        hexf (2*¯1022)÷2*4×⍪ 0 to 14        ⍝ denormal numbers.
    0010000000000000
    0001000000000000
    0000100000000000
    0000010000000000
    0000001000000000
    0000000100000000
    0000000010000000
    0000000001000000
    0000000000100000
    0000000000010000
    0000000000001000
    0000000000000100
    0000000000000010
    0000000000000001
    0000000000000000
:EndIf

⍝∇ hexf to

Back to: code

Back to: Workspaces