Core/CafeLib.Core.Encodings/Base58Encoder.cs
/// <summary>
/// Divides a number, represented as an array of bytes each containing a single digit
/// in the specified base, by the given divisor. The given number is modified in-place
/// to contain the quotient, and the return value is the remainder.
/// </summary>
/// <param name="number"> the number to divide </param>
/// <param name="firstDigit"> the index within the array of the first non-zero digit
///        (this is used for optimization by skipping the leading zeros) </param>
/// <param name="base"> the base in which the number's digits are represented (up to 256) </param>
/// <param name="divisor"> the number to divide by (up to 256) </param>
/// <returns> the remainder of the division operation </returns>
Divides a number, represented as an array of bytes each containing a single digit
in the specified base, by the given divisor. The given number is modified in-place
to contain the quotient, and the return value is the remainder.
Divides a number represented as an array of bytes each containing a single digit in the specified base by the given divisor . The given number is modified in - place to contain the quotient and the return value is the remainder .
private static byte DivMod(ByteSpan number, int firstDigit, int @base, int divisor)
        {
            var remainder = 0;
            for (var i = firstDigit; i < number.Length; i++)
            {
                var digit = number[i] & 0xFF;
                var temp = remainder * @base + digit;
                number[i] = (byte)(temp / divisor);
                remainder = temp % divisor;
            }
            return (byte)remainder;
        }
private static byte DivMod ( ByteSpan number , int firstDigit , int @base , int divisor ) { var remainder = 0 ; for ( var i = firstDigit ; i < number . Length ; i ++ ) { var digit = number [ i ] & 0xFF ; var temp = remainder * @base + digit ; number [ i ] = ( byte ) ( temp / divisor ) ; remainder = temp % divisor ; } return ( byte ) remainder ; }
Divides a number, represented as an array of bytes each containing a single digit
in the specified base, by the given divisor.
Divides a number represented as an array of bytes each containing a single digit in the specified base by the given divisor .
// this is just long division which accounts for the base of the input digits
the remainder of the division operation
the remainder of the division operation
number
ByteSpan
the number to divide
the number to divide
firstDigit
int
the index within the array of the first non-zero digit
(this is used for optimization by skipping the leading zeros)
the index within the array of the first non - zero digit ( this is used for optimization by skipping the leading zeros )
@base
int
divisor
int
the number to divide by (up to 256)
the number to divide by ( up to 256 )
base
the base in which the number's digits are represented (up to 256)
the base in which the number ' s digits are represented ( up to 256 )