| Crates.io | twos |
| lib.rs | twos |
| version | 0.0.1-alpha |
| created_at | 2025-08-08 08:01:57.126929+00 |
| updated_at | 2025-08-08 08:01:57.126929+00 |
| description | Command-line signed/unsigned integer converter utility (two's complement) |
| homepage | https://github.com/v-p-b/twos |
| repository | https://github.com/v-p-b/twos |
| max_upload_size | |
| id | 1786391 |
| size | 49,212 |
Signed/unsigned (two's complement) command-line integer converter based on num_bigint.
From crates.io:
cargo install twos
From source:
git clone https://github.com/v-p-b/twos
cd twos
cargo install --path .
Usage: twos [OPTIONS] <NUMBER>
Arguments:
<NUMBER> Number - "0x"/"0b" prefixes are recognized for hexadecimal/binary input
Options:
-b, --bits <BITS> Bit length (default: auto detect)
-n, --neg Treat value as negative magnitude (negative numbers don't play well with argument parsers...)
-h, --help Print help
-V, --version Print version
Get signed and unsigned values in different number systems:
% twos 0xdeadbeef
[ULEN] 32
[SLEN] 30
[UHEX] deadbeef
[SHEX] -21524111
[UBIN] 11011110101011011011111011101111
[SBIN] -100001010100100100000100010001
[UDEC] 3735928559
[SDEC] -559038737
Force wider integer width:
% twos -b 64 0xdeadbeef
[ULEN] 32
[SLEN] 32
[UHEX] deadbeef
[SHEX] deadbeef
[UBIN] 11011110101011011011111011101111
[SBIN] 11011110101011011011111011101111
[UDEC] 3735928559
[SDEC] 3735928559
Two's complement representation of negative values:
% twos -n 0xdeadbeef
[ULEN] 40
[SLEN] 32
[UHEX] ff21524111
[SHEX] -deadbeef
[UBIN] 1111111100100001010100100100000100010001
[SBIN] -11011110101011011011111011101111
[UDEC] 1095775699217
[SDEC] -3735928559