The precision of numbers in computer science varies as normally you cannot represent a real number with a finite representation in decimal (or binary) form. There are two ways of representing real numbers in approximate form. The first is fixed point numbers, where you deserve a number of bits for the integer part and some for the fractional part. The only fixed point number supported in C are integer (with 0 fractional bits) If you want more, you have to manage yourself.
The other class of real numbers is floating point... in this class you have relative error (it depends on the magnitude or how big the number is, the error you have) so... explained in decimal, when you have five digits for the mantissa, you'll get a 0.00001 * the_number
error or 0.001 %
error.
If you try to represent 10^100
as an integer, you'll need around 300 bits to represent such a big number, so it's impossible to do it exactly with the basic types allowed in C (even a long long long
, case it should be supported, is too small to allow such a number). If you try to represent it with the normal double
type, you'll get an error (0.000000000000001 %
over the magnitude of the result, of error)