Crate radix_fmt

source
Expand description

Latest Version Documentation

This crate adds a tool to format a number in an arbitrary base from 2 to 36.

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.

There is also one specific function for each radix that does not already exists in the standard library, e.g. radix_3 to format a number in base 3.

§Get started

Add the crate to the cargo manifest:

radix_fmt = "1"

Import radix in scope, and you are ready to go:

use radix_fmt::radix;

§Examples

use radix_fmt::*;

let n = 35;

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

You can use the alternate modifier to capitalize the letter-digits:

use radix_fmt::radix;

let n = 35;

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

Structs§

  • A struct to format a number in an arbitrary radix.

Functions§