The smallest possible floating point number, and the smallest possible
double-precision floating point number, depend on a number of factors.
A floating point number (both floats and doubles are floating point
numbers) consists of an exponent and a mantissa. Together, the number
of bits in the exponent plus the number of bits in the mantissa
comprise the total number of bits in the floating point number. The
number of bits in the exponent determines how big (or how small, which
is germane to your question) it can be.
If the exponent is 8 bits, for example, then it can range from -128 to
+127. The mantissa is taken to have an imaginary decimal point (more
correctly termed "binary point") before the first digit. It is
considered "normalized" when the first digit is 1. So, if the
exponent is 8 bits, regardless of the size of the mantissa, the
smallest normalized floating point number is 2^-65, or about
2.71051E-20.
Different computers (different CPU chips) have slightly different
conventions for interpreting the exponent, even if the exponents are
the same size. The example I gave is typically called the "excess-64"
convention. Other conventions, such as excess-63, or excess-62 would
also be possible. Also, different CPU chips might have different ways
to interpret the mantissa. The imaginary binary point need not be
before the first bit, for example.
So to know the smallest possible float, it is necessary to understand
the way the exponent is stored, and its interpretation (excess-64, for
example), and the way the mantissa is stored, and its interpretation
(location of the binary point). Also, it is important to know whether
a denormalized floating point number can be used in calculations
without causing overflow or "underflow".
The detailed specifications for your CPU chip should answer that type
of question. This type of question is known as an "architectural"
question, so an architecture (or functional specification) manual for
your CPU would need to be consulted to fully answer it.
If this is the sort of answer you had in mind, then can you clarify
your question to indicate this, and in your clarification, can you
indicate which CPU you are using?
I see, too, in your question that you are looking for an "algorithm".
That might mean you want to write a program, in C perhaps, that will
run on a computer and determine what its smallest floating point
number is. That way, the program could be compliled on any computer,
and run as a test to see what the smallest floating point number is.
If that's what you meant, then can you clarify your question to say
that? |