Hi guys.
The following line:
cout << 1/1000000000;
gives 0. I thought that this is a question of representing small numbers but this line gives 0 as well:
cout << (1/1000000000) * 1000000000;
This line however is OK:
cout << 1e-9;
Why is that so?
Thanks.
1/2 will give 0 too. That is because this is integer division. Divide doubles (or floats).
either double(1)/2 or 1.0/2