Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- unsigned long long power,incorrect,incorrect2,incorrect3,incorrect4,incorrect5;
- unsigned long long correct,correct2,correct3,correct4;
- double power2,power3;
- power = 7 * pow(10, 17); // outputs 700000000000000000
- power2 = pow(10, 17); // outputs 100000000000000000.000000
- power3 = 7.0 * pow(10, 17); // outputs 700000000000000000.000000
- printf ("printf_power %lld\n", power);
- printf ("printf_power2 %f\n", power2);
- printf ("printf_power3 %f\n", power3);
- correct = 42105263157890000 + power; // outputs 742105263157890000
- correct2 = 42105263157890000 + 700000000000000000; // outputs 742105263157890000
- correct3 = 42105263157890000 + (unsigned long long)(7 * pow(10, 17)); // outputs 742105263157890000
- correct4 = 42105263157890000 + power; // outputs 742105263157890000
- cout << "correct " << correct << "." << endl;
- cout << "correct2 " << correct2 << "." << endl;
- cout << "correct3 " << correct3 << "." << endl;
- cout << "correct4 " << correct4 << "." << endl;
- incorrect = 42105263157890000 + (7 * pow(10, 17)); // outputs 74210526315789048
- incorrect2 = 42105263157890000 + (7 * 100000000000000000.00); // outputs 74210526315789048
- incorrect3 = 42105263157890000 + (7.0 * 100000000000000000.00); // outputs 74210526315789048
- incorrect4 = 42105263157890000 + 700000000000000000.00; // outputs 74210526315789048
- incorrect5 = 42105263157890000.00 + 700000000000000000.00; // outputs 74210526315789048
- double incorrect6 = 42105263157890000.00 + 700000000000000000.00; // outputs 74210526315789048.000000
- cout << "incorrect " << incorrect << "." << endl;
- cout << "incorrect2 " << incorrect2 << "." << endl;
- cout << "incorrect3 " << incorrect3 << "." << endl;
- cout << "incorrect4 " << incorrect4 << "." << endl;
- cout << "incorrect5 " << incorrect5 << "." << endl;
- printf ("incorrect6 %f\n", incorrect6);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement