bits-cli

Crates.iobits-cli
lib.rsbits-cli
version0.1.0
sourcesrc
created_at2023-11-29 21:49:28.936699
updated_at2023-11-29 21:49:28.936699
descriptionConverts input into bits (with explanations, where applicable)
homepagehttps://github.com/sunsided/bits
repositoryhttps://github.com/sunsided/bits
max_upload_size
id1053603
size38,491
Markus Mayer (sunsided)

documentation

README

bits

Converts input into bits (with explanations, where applicable).

Example

When run with e.g. bits -0.3, the output is

f16:  1011010011001101
      SEEEEEMMMMMMMMMM
      S: Sign (1 bit)
      E: Exponent (5 bits)
      M: Fraction / Mantissa (10 bits)
bf16: 1011111010011010
      SEEEEEEEEMMMMMMM
      S: Sign (1 bit)
      E: Exponent (8 bits)
      M: Fraction / Mantissa (7 bits)
f32:  10111110100110011001100110011010
      SEEEEEEEEMMMMMMMMMMMMMMMMMMMMMMM
      S: Sign (1 bit)
      E: Exponent (8 bits)
      M: Fraction / Mantissa (23 bits)
f64:  1011111111010011001100110011001100110011001100110011001100110011
      SEEEEEEEEEEEMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
      S: Sign (1 bit)
      E: Exponent (11 bits)
      M: Fraction / Mantissa (52 bits)

If only some types are required, the --type=... option can be used, e.g. bin --type=f16,f32 -0.3 which gives

f16:  1011010011001101
      SEEEEEMMMMMMMMMM
      S: Sign (1 bit)
      E: Exponent (5 bits)
      M: Fraction / Mantissa (10 bits)
f32:  10111110100110011001100110011010
      SEEEEEEEEMMMMMMMMMMMMMMMMMMMMMMM
      S: Sign (1 bit)
      E: Exponent (8 bits)
      M: Fraction / Mantissa (23 bits)

Full, short and very short format

By default, --display=full is implied, showing all information. If only type and bit information are wished, --display=short can be used:

f16:  1011010011001101
f32:  10111110100110011001100110011010

If only the bits are wished for, the --display=very-short format exists, removing even the type information:

1011010011001101
10111110100110011001100110011010

The very short format makes most sense in combination with specific types; in the example above, --type=f16,f32 was used.

Commit count: 15

cargo fmt