format bits
for conversions
Convert value to a string of binary data represented by 0 and 1.
Signature
> format bits {flags} ...rest
Parameters
...rest
: For a data structure input, convert data at the given cell paths.
Input/output types:
input | output |
---|---|
binary | string |
bool | string |
duration | string |
filesize | string |
int | string |
record | record |
string | string |
table | table |
Examples
convert a binary value into a string, padded to 8 places with 0s
> 0x[1] | format bits
00000001
convert an int into a string, padded to 8 places with 0s
> 1 | format bits
00000001
convert a filesize value into a string, padded to 8 places with 0s
> 1b | format bits
00000001
convert a duration value into a string, padded to 8 places with 0s
> 1ns | format bits
00000001
convert a boolean value into a string, padded to 8 places with 0s
> true | format bits
00000001
convert a string into a raw binary string, padded with 0s to 8 places
> 'nushell.sh' | format bits
01101110 01110101 01110011 01101000 01100101 01101100 01101100 00101110 01110011 01101000