So im into my first 9hours of programming day and a problem occured.
While using the pow() function i had to search to make it work actually and now it wont calculate accuratly above 9.
here is the piece of code.
if ( prog == 2 )
{
cout<<"geef het cijfer in dat je wil omrekenen naar machten";
cout<<"\n";
cin >> a;
cout<<"geef nu het aantal machten aan";
cout<<"\n";
cin >> b;
cout << a; cout <<" tot de macht "; cout << b; cout<<" is";
cout<<"\n";
cout<<static_cast<int>(pow(static_cast<double>(a),b));
cout<<"\n";
cout<<"\n";
}
The problem there is that a signed int value, which I'm guessing on your machine is 32 bits, can hold roughly the values
−2,147,483,648 to 2,147,483,647 (i.e. from −(2^31) to 2^31 − 1)
You will note that the value you are getting is the lower bound, suggesting that some kind of overflow has happened. Since 10^10 is 10 000 000 000, which is much larger than 2,147,483,647, it is impossible for an int to hold this value.
If you want to calculate this value, you will have to use a datatype that can handle it.
You could learn about datatypes and see which of them can handle the numbers you expect to work with.
For example, you might decide you wanted to understand what an int is, so you would look here http://en.wikipedia.org/wiki/Integer_(computer_science) and see what values can be represented using signed and unsigned integers of various bit sizes.
You might decide that you need arbitrarily large integer types, and look into the common bignum libraries (such as http://gmplib.org/ ).
The point here is that you have realised that the computer cannot handle the infinite range of numbers that your mind can handle, and you will have to start learning about how it actually represents numbers, and you will have to decide what tradeoffs to make in in programming.
try this: http://orwellengine.blogspot.com/ I used to work on dev-c++ but it's far outdated, so if you want something OK, and keep the basic dev-c++ syntax, use the Orwell's update. It's realy awsome!