| Crates.io | radix_fmt_ng |
| lib.rs | radix_fmt_ng |
| version | 1.0.0 |
| created_at | 2025-07-23 12:47:24.924394+00 |
| updated_at | 2025-07-23 12:47:24.924394+00 |
| description | Format a number in an arbitrary radix |
| homepage | |
| repository | https://github.com/Krysztal112233/radix_fmt_ng |
| max_upload_size | |
| id | 1764759 |
| size | 33,232 |
This crate adds a tool to format a number in an arbitrary base from 2 to 61.
This is a light crate, without any dependency.
For primitive signed integers (i8 to i128, and isize), negative values are formatted as the two’s complement representation.
Add the crate in the cargo manifest:
radix_fmt_ng = "1"
Import radix in scope, and you are ready to go:
use radix_fmt_ng::radix;
use radix_fmt_ng::*;
let n = 35;
// Ouput: "z"
println!("{}", radix(n, 36));
No. If you did that the conversion from 36 to 61 would be meaningless.
Just as in the standard library, when a number is formatted in a non-decimal base, the two’s complement representation is used. That means that the number is casted to the unsigned version (for example, for an
i8the following number is used:n as u8).