In some scenarios/applicatons, where the precision may not be so critically important but the speed (performance) is, you may be willing to sacrifice some extent of accuracy for the …
In Java Math Package, there is a pow function with returns double type. However, we can speed up this if only integer (long type) parameters are required, i.e. compute integer power …
Given a signed-integer, we can use the following straightforward method to judge it is the power of two inline bool check1(int i) { if (i < 1) return false; …
A bit is set if it is ‘1’. To count how many ‘set’ bits in a 32-bit integer (signed or unsigned), we can use the following straightforward method: inline …
Computers cannot generate (or very difficult) true random numbers. In practise, psudo-random generators are used. To avoid ‘patterns’ for generated ‘random’ numbers, a seed is often used to re-arrange …
Usage of Multi-Dimensional Array is popular. For example, a 2-dimension array can be created to represent a chess board state. If we want to clear the state of the …