Packages

Byte Utilities for BitArrays.

Current section

Files

Jump to
bits README.md
Raw

README.md

# bits

<!-- [![Package Version](https://img.shields.io/hexpm/v/bits)](https://hex.pm/packages/bits) -->
<!-- [![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://bits.hexdocs.pm/) -->

```sh
gleam add bits
```
```gleam
import bits

pub fn main() -> Nil {
  assert Ok(13.37) == bits.to_float(<<"13.37">>)
  assert Ok(1337.0) == bits.to_float(<<"1337">>)
  assert Ok(1337) == bits.to_int(<<"1337">>)

  assert Error(Nil) == bits.to_float(<<"Leet">>)
  assert Error(Nil) == bits.to_int(<<"Leet">>)

  assert <<"13.37">> == bits.from_float(13.37, 2)
  assert <<"1337.0">> == bits.from_float(1337.0, 1)
  assert <<"1337">> == bits.from_int(1337)

  let assert <<code>> = <<" ">>
  assert Ok(8) == bits.find_byte(<<"Icecream Sandwich">>, code)
}
```

<!-- Further documentation can be found at <https://bits.hexdocs.pm/>. -->

## Development

```sh
gleam test  # Run the tests
```

## Provenance
The project only contains artisanal code. **No** AI generation or assistance is used to implement any functionality.

## LICENSE
bits is made available under the terms of the EUPL-1.2 License.