#format #bignum #convert #stoichiometry

no-std stoich

Conversion between bigint formats; integer stoichiometry

1 stable release

Uses new Rust 2024

1.0.0 Mar 15, 2026

#2184 in Algorithms


Used in ious

Custom license

80KB
1.5K SLoC

stoich

Conversion between bigint formats; integer stoichiometry.

Summary

The name "stoich" comes from the term "stoichiometry," the mathematics of balancing the quantities of chemicals in a reaction under the assumption that no elements are added or subtracted, just moved around.

This library lets you convert between different bigint formats by rearranging their constituent parts.

Benchmarking

Benchmarks for this library are done via Gungraun, using cachegrind to generate statistics and callgrind to generate runtime info for potential debugging. While the conversions are not entirely optimized out (since that'd be pointless), some checks are explicitly optimized out to ensure a more realistic use case where most pre-checks are implicitly satisfied. (Since users have likely already chosen an explicit combination of types, they're likely to provide buffers that are always correctly aligned, and/or pairs of buffers whose sizes and alignments correctly match.)

The goal with using a "one-shot" benchmarking strategy over a statistical one is that because the code explicitly deals with copying buffers, the performance will be particularly sensitive to pre-emption of the process, more so than the code's actual performance. Since the goal is going to be reduce the actual amount of run code as much as possible, the statistics from cachegrind are much likely to be more fruitful to measure than runtime.

License

Released under the copyleft Parity License.

Dependencies

~125KB