Module lexical_util::step
source · Expand description
The maximum digits that can be held in a u64 for a given radix without overflow.
This is useful for 128-bit division and operations, since it can reduces the number of inefficient, non-native operations.
§Generation
See etc/step.py
for the script to generate the divisors and the
constants, and the division algorithm.
Functions§
- Calculate the maximum number of digits that can be processed without always overflowing for a given type. For example, 20 digits can be processed for a decimal string for
u64
without overflowing, but it may overflow. - Calculate the maximum number of digits that can always be processed without overflowing for a given type. For example, 19 digits can always be processed for a decimal string for
u64
without overflowing. - Calculate the number of digits that can be processed without overflowing a u64. Helper function since this is used for 128-bit division.