fork download
  1. #include <stdio.h>
  2. #include <quadmath.h>
  3.  
  4. void p(int x,int y) {
  5. __float128 f = 1.0Q * x / y;
  6. __float128 d = f*f-2.0Q;
  7. printf("%d / %d = %.30Lf\n(%d/%d)^2 - 2 = %.30Lg\n\n",
  8. x, y, (long double)f, x, y, (long double)d);
  9. }
  10.  
  11. int main(void) {
  12. p(30547,21600);
  13. p(66922,47321);
  14. p(47321,33461);
  15. return 0;
  16. }
  17.  
Success #stdin #stdout 0s 2188KB
stdin
Standard input is empty
stdout
30547 / 21600 = 1.414212962962962962919916121152
(30547/21600)^2 - 2 = -1.69538751714677640605831415821e-06

66922 / 47321 = 1.414213562688869635038980965280
(66922/47321)^2 - 2 = 8.93145405137925495280671784663e-10

47321 / 33461 = 1.414213562057320462597015398032
(47321/33461)^2 - 2 = -8.93145404739071138128180625993e-10