hex  ← ##.hexf nums                 ⍝ (big-endian) hex display of float array.
nums ← ##.decf hex                  ⍝ Numbers from (big-endian) floating hex.

These  functions  convert  between  a simple numeric argument and its equivalent
hexadecimal IEEE double floating-point representation.

The  hexadecimal  display  is in big-endian format with the sign and exponent in
the left-most 12 bits.

    hexf 3          ⍝ sign 0, exponent 400, (elided 1) mantissa binary 10000 ...
4008000000000000

    decf hexf 3     ⍝ (round-trip).
3

See: http://en.wikipedia.org/wiki/IEEE_754-1985 for details.

Examples:

    nmat←÷2 3⍴⍳6            ⍝ simple numeric array.

    nmat                    ⍝ display of array.
1    0.5 0.3333333333
0.25 0.2 0.1666666667

    hexf nmat               ⍝ hex display of floating array.
3FF0000000000000 3FE0000000000000 3FD5555555555555
3FD0000000000000 3FC999999999999A 3FC5555555555555

    nmat ≡ decf hexf nmat   ⍝ check round-trip.
1

See also: hex dec

Back to: contents

Back to: Dyalog APL

Trouble seeing APL font?