format bits for conversions
Convert value to a string of binary data represented by 0 and 1.
Signature
> format bits {flags} ...rest
Flags
--endian, -e {string}: Byte encode endian. Only applies to int, filesize, duration and bool, as well as tables and records of those. Available options: native, little, big(default)
Parameters
...rest: For a data structure input, convert data at the given cell paths.
Input/output types:
| input | output |
|---|---|
| binary | string |
| int | string |
| filesize | string |
| duration | string |
| string | string |
| bool | string |
| table | table |
| record | record |
Examples
convert a binary value into a string, padded to 8 places with 0s
> 0x[1] | format bits
00000001convert an int into a string, padded to 8 places with 0s
> 1 | format bits
00000001convert an int into a string, padded to 8 places with 0s (big endian)
> 258 | format bits
00000001 00000010convert an int into a string, padded to 8 places with 0s (little endian)
> 258 | format bits --endian little
00000010 00000001convert a filesize value into a string, padded to 8 places with 0s
> 1b | format bits
00000001convert a duration value into a string, padded to 8 places with 0s
> 1ns | format bits
00000001convert a boolean value into a string, padded to 8 places with 0s
> true | format bits
00000001convert 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