Precision Numeric in C++

Hi.

I'm trying to verify which is the numerical presicion of my computer...

my code:

#include <iostream>
#include <iomanip>

using namespace std;

int main(int argc, char **argv)
{
double a;

a = 1.00000000000100000000;

cout.precision(30);
cout << a << endl;
return 0;
}

but the answer of my computer in terminal is:
1.00000000000100008890058234101

why happen this?
Is there any way to get the right answer?

Thanks.
¡Amazing!. Thank you Bazzy.

So even though I use libraries like libgmp this problem has no solution? (Excuse my English)
Multiple precision libraries can extend the numeric precision up to get all available memory so you wouldn't have these problems
What does GMP have to do with this? You're using regular doubles.
In any case, it's impossible for a computer to represent all values on the Real line. Libraries such as GMP only offer arbitrary precision, not infinite precision.
"....arbitrary precision, infinite precision..." What's difference? (helios)
"Infinite" means "unbounded". Computers are physically incapable of handling infinite amounts of data.
"Arbitrary" means "as much as needed within the system's limits". The limit is the amount of available memory. For example, a computer with 2^32 bytes of memory could in principle represent all integers in the range [0;2^(8*2^32)).
Topic archived. No new replies allowed.