By bit shifting an unsigned long until its most significant bit is 1, the most significant non-zero bit can be determined. This function operates at a constant speed no matter the input. This is accomplished by performing a form of binary search, checking which half of the total space of integers the given integer presides in.
This functions returns the greatest integer less than or equal to the square root of the input. numBits(sqrt(n))
must be at most (numBits(n) + 1) / 2
, as upperBound / 2
. This is because
This functions returns the greatest integer less than or equal to the square root of the input. numBits(cbrt(n))
must be at most (numBits(n) + 2) / 3
, as upperBound / 4
. This is because
This functions returns the greatest integer less than or equal to the square root of the input. numBits(nthRoot(x))
must be at most (numBits(x) + n - 1) / n
, as upperBound / (1 << numBits - 1)
. This is because exp()
which is performed in exp()
call, these time complexities are multiplied together.
This returns an estimation of the square root of 2 using a recursive formula along with the error bounds of the estimation. The error bounds are calculated by retrieving the next estimate, subtracting the requested estimate from it, and taking its absolute value. A proof for the formula is attached. (I know I could've done it with matrices, I don't want to though)
This sets a given char
array to be equal the quaternary representation of an unsigned long where the 0th index is the least signficant digit and the 5th index is the most signficant.
The function is
This returns the dozenal()
.
By reading in the base 12 representation of the exponent backwards starting from the 0 one position of significance below the most significant non-zero digit. The number is divided by 12 each iteration and a number accumulator
to the power of 12 as accumulator
by the given base as