Use any characters as your own numeric base and convert to and from decimal.
base_custom alternatives and similar packages
Based on the "Data structures" category.
Alternatively, view base_custom alternatives based on common mentions on social networks and blogs.
roaring-rs6.0 5.1 base_custom VS roaring-rsA better compressed bitset in Rust
generic-array5.2 5.9 base_custom VS generic-arrayGeneric array types in Rust
array_tool2.4 5.4 base_custom VS array_toolArray helpers for Rust's Vector and String types
NumToA1.8 0.9 base_custom VS NumToAAn efficient method of heaplessly converting numbers into their string representations, storing the representation within a reusable byte array.
enum-map1.3 0.0 base_custom VS enum-mapAn optimized map implementation for enums using an array to store values.
contain-rsExtension of Rust's std::collections
Access the most powerful time series database as a service
Do you think we are missing an alternative of base_custom or a related project?
Use any characters as your own numeric base and convert to and from decimal. This can be taken advantage of in various ways:
- Mathematics: number conversion
- Brute force sequencing
- Rolling ciphers
- Moderate information concealment
- Other potential uses such as deriving music or art from numbers
There is also a Ruby and Crystal implementation of this which this was based off of.
Add the following to your Cargo.toml file
[dependencies] base_custom = "^0.2"
To include it for usage add
extern crate base_custom; use base_custom::BaseCustom;
to your file.
// Binary with no delimiter let base2 = BaseCustom::<char>::new("01".chars().collect()); assert_eq!(base2.decimal("00001"), 1_u64); assert_eq!(base2.decimal("100110101"), 309_u64); assert_eq!(base2.gen(340), "101010100"); assert_eq!(base2.gen(0xF45), "111101000101"); assert_eq!(base2.gen(0b111), "111"); // Trinary with no delimiter let base3 = BaseCustom::<char>::new("ABC".chars().collect()); assert_eq!(base3.decimal("ABC"), 5); assert_eq!(base3.gen(123), "BBBCA"); // Custom base like Musical Chords and a space delimiter let base_music = BaseCustom::<String>::new("A A# B C C# D D# E F F# G G#", Some(' ')); assert_eq!(base_music.decimal("F F# B D# D A# D# F# "), 314159265); assert_eq!(base_music.gen(314159265), "F F# B D# D A# D# F# ");
BaseCustom::<String>::new the second parameter must be of
choose your optional delimiter.
Benchmarks are provided for the various usages and implementations.
by far the most efficient implementation.
Licensed under either of
- Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
*Note that all licence references and agreements mentioned in the base_custom README section above are relevant to that project's source code only.