>>  <<  Ndx  Usr  Pri  JfC  LJ  Phr  Dic  Rel  Voc  !:  wd  Help  Dictionary

Conversions 3!:

3!:0 y Type. The internal type of the noun y , encoded as follows:
1 boolean
2 literal
4 integer
8 floating point
16 complex
32 boxed
64 extended integer
128  rational
     
1024 sparse boolean
2048 sparse literal
4096 sparse integer
8192 sparse floating point
16384 sparse complex
32768 sparse boxed
65536 symbol
131072  unicode
 
[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.

flag1 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
type1 mwordas in 3!:0
#elements1 mword*/$y if dense; 1 if sparse
rank1 mword#$y
shaperank mwords$y
value? mwordsthe 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.

 
3!:2 y Convert from Binary/Hex Representation. Inverse of 3!:1 and of 3!:3 ; works on an argument in either word size and in either byte order. If the first byte of the flag part (see 3!:1 above) is not one of e0 e1 e2 e3 , then the conversion proceeds under the assmption that the data is pre-J6.01.

 
[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 then years ago'
   $t
44 8
   12{.t
e0000000
00000020
00000005
00000001
00000005
00000028
00000048
00000060
0000007c
00000098
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|00000004|00000005|00000003|
|00000001|00000001|00000001|00000001|00000001|00000001|
|00000005|00000009|00000003|00000004|00000005|00000003|
|00000028|666f7572|616e6400|7468656e|79656172|61676f00|
|00000048|73636f72|        |00000000|73000000|        |
|00000060|65000000|        |        |        |        |
|0000007c|        |        |        |        |        |
|00000098|        |        |        |        |        |
+--------+--------+--------+--------+--------+--------+
3!:4 y
3!:5 y
Integer/Floating Conversion. If ic=: 3!:4 and fc=: 3!:5 , then

 3 ic y   J integers to sets of 8 bytes (J64 only)
_3 ic y sets of 8 bytes to J integers (J64 only)
 2 ic y   J integers to sets of 4 bytes
_2 ic y sets of 4 bytes to J integers
 1 ic y J integers to sets of 2 bytes
_1 ic y sets of 2 bytes to J integers
 0 ic y sets of 2 bytes interpreted as unsigned integers to J integers
 
 2 fc y J floats to binary doubles
_2 fc y binary doubles to J floats
 1 fc y J floats to binary short floats
_1 fc y binary short floats to J floats

All ranks are infinite and all inverses of k&ic and k&fc exist for non-zero k .
 
3!:6 y Lock Script. Converts plain script text into locked script text.



>>  <<  Ndx  Usr  Pri  JfC  LJ  Phr  Dic  Rel  Voc  !:  wd  Help  Dictionary