[x] 3!:1 y |
Convert to Binary Representation.
In standard byte order, the bytes of a word are listed
from most significant to least significant; in reverse byte order,
the bytes are listed from least significant to most significant.
For example, the 4-byte integer 265358979 is 0fd10e83 in
standard byte order and 830ed10f in reverse byte order.
The PC is a reverse byte order machine.
The dyad x 3!:1 y applies to an array y and produces its
binary representation, according to the atom x :
| x | word size | byte order |
| 0 | 32 bits | standard |
| 1 | 32 bits | reverse |
| 2 | 64 bits | standard |
| 3 | 64 bits | reverse |
For backward compatibility, x may be 10 instead of 2 and 11 instead of 3.
The monad 3!:1 produces the binary representation
in the word size and byte order of the current machine.
The result of 3!:1 y or x 3!:1 y consists
of the following parts. An mword (machine word) is either 32-bits or 64 bits as
determined from x , or from the current machine if x is elided.
flag | 1 mword |
The first byte is one of the following:
e0 | | 32 bits, standard |
e1 | | 32 bits, reverse |
e2 | | 64 bits, standard |
e3 | | 64 bits, reverse |
|
type | 1 mword | as in 3!:0 |
#elements | 1 mword | */$y if dense; 1 if sparse |
rank | 1 mword | #$y |
shape | rank mwords | $y |
value | ? mwords | the ravelled elements of y |
Ravelled elements for the boxed, extended integer, rational, and sparse types
are byte offsets to the representations of the elements.
See 3!:3 below for examples.
|
[x] 3!:3 y |
Hex Representation. Like 3!:1 , but the
result is a literal matrix of the hexadecimal representation.
For example, under 32-bit Windows:
(3!:3 x) ; (3!:3 x,o.1) ; 2 (3!:3) x,o.1 [ x=: 1 2 3 0 _1
+--------+--------+----------------+
|e1000000|e1000000|e200000000000000|
|04000000|08000000|0000000000000008|
|05000000|06000000|0000000000000006|
|01000000|01000000|0000000000000001|
|05000000|06000000|0000000000000006|
|01000000|00000000|3ff0000000000000|
|02000000|0000f03f|4000000000000000|
|03000000|00000000|4008000000000000|
|00000000|00000040|0000000000000000|
|ffffffff|00000000|bff0000000000000|
| |00000840|400921fb54442d18|
| |00000000| |
| |00000000| |
| |00000000| |
| |0000f0bf| |
| |182d4454| |
| |fb210940| |
+--------+--------+----------------+
t=: 0 (3!:3) ;:'fourscore and ten years ago'
$t
43 8
12{.t
e0000000
00000020
00000005
00000001
00000005
00000028
00000048
00000060
00000078
00000094
e0000000
00000002
dfh=: 16 #. '0123456789abcdef' i. ] NB. decimal from hex
((i.#t) e. 0,4 %~ dfh (5+i.5){t) <;.1 t
+--------+--------+--------+--------+--------+--------+
|e0000000|e0000000|e0000000|e0000000|e0000000|e0000000|
|00000020|00000002|00000002|00000002|00000002|00000002|
|00000005|00000009|00000003|00000003|00000005|00000003|
|00000001|00000001|00000001|00000001|00000001|00000001|
|00000005|00000009|00000003|00000003|00000005|00000003|
|00000028|666f7572|616e6400|74656e00|79656172|61676f00|
|00000048|73636f72| | |73000000| |
|00000060|65000000| | | | |
|00000078| | | | | |
|00000094| | | | | |
+--------+--------+--------+--------+--------+--------+
|