4
Rounding
- #include <iostream>
- int main() {
- using namespace std;
- double x = 1000/3.0; cout << "x = " << x << endl;
- double y = x - 333.0; cout << "y = " << y << endl;
- double z = 3*y - 1.0; cout << "z = " << z << endl;
- cout << "3*y - 1.0 = " << 3*y << " - " << 1.0 << " = " << z << endl;
- if ( z == 0.0 )
- cout << "z is null!" << endl;
- else
- cout << "z is NOT null!" << endl;
- }
Commentaires