radix_fmt_ng 1.0.0

Format a number in an arbitrary radix
Documentation
  • Coverage
  • 100%
    4 out of 4 items documented3 out of 4 items with examples
  • Size
  • Source code size: 32.73 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.93 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 14s Average build duration of successful builds.
  • all releases: 14s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Krysztal112233/radix_fmt_ng
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Krysztal112233

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).