https://github.com/rmja/nobcd
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/rmja/nobcd
- Owner: rmja
- Created: 2022-12-16T14:01:27.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2025-02-11T09:45:37.000Z (over 1 year ago)
- Last Synced: 2025-07-25T04:39:16.198Z (11 months ago)
- Language: Rust
- Size: 18.6 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# A simple BCD number primitive
[](https://github.com/rmja/nobcd/actions/workflows/ci.yml)
[](https://crates.io/crates/nobcd)
This crate provides a simple `BcdNumber` type that can be used in embedded `no_std` environments.
If you are missing a feature, please raise an issue or a PR.
## Example
```rust
let bcd = BcdNumber::<2>::try_new(1234u16).unwrap();
assert_eq!(1234u16, bcd.value());
assert_eq!([0x12, 0x34], bcd.bcd_bytes());
assert_eq!(bcd, BcdNumber::try_from([0x12, 0x34]).unwrap());
```