radix_fmt_ng

Crates.ioradix_fmt_ng
lib.rsradix_fmt_ng
version1.0.0
created_at2025-07-23 12:47:24.924394+00
updated_at2025-07-23 12:47:24.924394+00
descriptionFormat a number in an arbitrary radix
homepage
repositoryhttps://github.com/Krysztal112233/radix_fmt_ng
max_upload_size
id1764759
size33,232
Krysztal Huang (Krysztal112233)

documentation

https://docs.rs/radix_fmt_ng/

README

Latest Version Documentation

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.

Get started

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;

Examples

use radix_fmt_ng::*;

let n = 35;

// Ouput: "z"
println!("{}", radix(n, 36));

FAQ

  • What if I want to use the capitalized letters as digits?

No. If you did that the conversion from 36 to 61 would be meaningless.

  • Why does the formatting of negative numbers give a weird result?

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 i8 the following number is used: n as u8).

Commit count: 0

cargo fmt