bin - binary value
Returns a random binary value or converts a decimal value to binary depending on the parameters.
Binary numeral system, or base-2 numeral system, represents numeric values using two symbols: 0 and 1.
Source: http://en.wikipedia.org/wiki/Binary_numeral_system
Note: To randomly generate bytes (groups of 8bits with leading zero's), use the byte() function.
Usage(s)
bin ( $decimal ) |
converts the $decimal value to binary |
bin ( $minimum , $maximum ) |
Returns a random binary value in the decimal range minimum to maximum. |
Parameter(s)
$decimal |
A decimal integer value |
$minimum |
The minimum value for the range. |
$maximum |
The maximum value for the range. |
Example(s)
Converting decimals to binary
bin(170) will always return 10101010 as binary value
|
Generating random binary values
bin(0,255) x 20
Could return:
10101110
10010011
11111001
10000001
1011000
100101
10110001
11011001
100110
1011000
11001111
11111011
10110111
1111011
10000000
11100000
111111
11100111
1110010
1100111
|
See also
int - number
hex - hexadecimal value
byte - eight bits
oct - octal values