A method and apparatus for testing random numbers generated by a random-number
generator in real time. A stream of random bits generated by the random-number
generator is segmented into a predefined block of bits, then these blocks undergo
a gap-length-calculation operation in which it is determined for which specific
range the gap belongs to, then these gap length values are applied to an exponential-counting
operation to obtain and update gap-frequency values for different bit patterns
and gap ranges. Thereafter, the updated gap-frequency values are compared to at
least one predetermined acceptance range, so that if at least one of the gap-frequency
values falls repeatedly outside the predetermined acceptance range more than a
predetermined number of times, it is determined that the generated random bits
are insufficiently random.