A crate and an app to convert any integer from one numeral system to another.
Two numeral systems must be defined : one for the input number and one for the output.
Any integer (of any length) can then be converted from one system to the other and vice-versa.
This library uses shift-adjust algorithm (and reversed shift-adjust) to convert numbers. Binary is used as a pivot radix. This method was described here : Convert binary number to any base.
It was named after french singer (and also mathematician) Boby Lapointe who invented the Bibi-binary system in 1968.
Exemple
extern crate bibicode;
let dec = new.unwrap;
let bibi = new.unwrap;
let coder = new;
let test = coder.swap.unwrap;
assert_eq!;
let bibi = new.unwrap;
let dec = new.unwrap;
let coder = new;
let test = coder.swap.unwrap;
assert_eq!;
// with prefixed numeral system
let dec = new.unwrap;
let hex = new.unwrap;
let coder = new;
let test = coder.swap.unwrap;
assert_eq!;
let dec = new.unwrap;
let hex = new.unwrap;
let coder = new;
let test = coder.swap.unwrap;
assert_eq!;
// will also work
let test = coder.swap.unwrap;
assert_eq!;
Example : using application
$ bibicode 1111111111111111 -f bin -t hex
0xffff
$ bibicode ffff -t bin -f hex
0b1111111111111111
$ bibicode ffffffffffffffffffffffffffffffff -t dec -f hex
340282366920938463463374607431768211455
$ bibicode 340282366920938463463374607431768211455 -f dec -t hex
0xffffffffffffffffffffffffffffffff
$ cat ./examples/bibi.json
{
"prefix":"",
"digits":["HO", "HA", "HE", "HI", "BO", "BA", "BE", "BI", "KO", "KA", "KE", "KI", "DO", "DA", "DE", "DI"]
}
$ bibicode 340282366920938463463374607431768211455 -f dec -t ./examples/bibi.json
DIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDIDI
$ bibicode 5454366920938463463375407431768211455 -f dec -t ./examples/bibi.json
BOHAKEBIKAHODAHIKADIDEDAKAKOBOKOHADIBEDADOBEHOKOHIDAHADIDIDIDI
$ bibicode 5454366920938463463375407431768211455 -f dec -t utf8
■♢♥♢♥♤♣♧★○■☆♠◇♥♧♠♡♣♤♠⚐♦♡■⚐♥♤◀⚐♣◇●◁◀♡♦♢