Core Function Bin
From Sputnik Wiki
Bin( <args> )
Contents |
Description
Create a new binary variable.
Parameters
args
One or more things to place into the new binary variable.
Return Value
Returns the new binary variable.
Remarks
None.
Example
Using bin() to create binary:
$bin = bin(72, 101, 108, 108, 111); printr $bin; // Prints: // Binary // ( // [0] => 72 // [1] => 101 // [2] => 108 // [3] => 108 // [4] => 111 // )
Of course bin() can use hex:
$bin = bin(0x48, 0x65, 0x6C, 0x6C, 0x6F); printr $bin; // Prints: // Binary // ( // [0] => 72 // [1] => 101 // [2] => 108 // [3] => 108 // [4] => 111 // )
Binary will always try print as an ASCII string example
$bin = bin(0x48, 0x65, 0x6C, 0x6C, 0x6F); say $bin; // Prints: // Hello
Bin() supports a number of cool stuff like sequences
$bin = bin(@'A', 'B'..'G', 0x10..0x15, 5..8); printr $bin; say BinaryExpand($bin); // Prints // Binary // ( // [0] => 65 // [1] => 66 // [2] => 67 // [3] => 68 // [4] => 69 // [5] => 70 // [6] => 71 // [7] => 16 // [8] => 17 // [9] => 18 // [10] => 19 // [11] => 20 // [12] => 21 // [13] => 5 // [14] => 6 // [15] => 7 // [16] => 8 // ) // 00 | 41 42 43 44 45 46 47 10 11 12 13 14 15 05 06 07 ABCDEFG......... // 01 | 08 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- .