I don't understand how C++ cannot make simple calculations like a simple calculator. I have code producing wrong results with double division and multiplication. An example:
#include <iostream>
int main()
{
double a = 0.00001;
int b = 1/a;
std::cout <<b<<std::endl;
return 0;
}
This gives 99999 when it's supposed to give 100000. How can I have the right result?
Windows 7 64 bit, MSVC2012
Edit: Thank you for the explanation. I deduct that to solve my problem I have to round it before casting to int. I wonder if this is the default way of doing it as this kind of error doesn't seem acceptable to any program based on decimal calculations.