fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6. int main() {
  7. double a = pow(10, -300);
  8. double b = pow(10, -308);
  9.  
  10. cout << setprecision(50);
  11.  
  12. cout << "The reasonable way: " << a/b << endl;
  13. cout << "The wacky way: " << exp(log(a)-log(b)) << endl;
  14. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
The reasonable way: 100000000.00000001490116119384765625
The wacky way: 100000000.0000037252902984619140625