#include <bits/stdc++.h>
using namespace std;
signed long long tonum(string s) {
  stringstream in(s);
  signed long long x;
  in >> x;
  return x;
}
string tostr(signed long long n) {
  stringstream in;
  in << n;
  string x;
  in >> x;
  return x;
}
signed long long gcd(signed long long a, signed long long b) {
  while (1) {
    a = a % b;
    if (a == 0) return b;
    b = b % a;
    if (b == 0) return a;
  }
}
int main() {
  int T;
  cin >> T;
  signed long long A, B;
  while (T--) {
    cin >> A >> B;
    if (A == 0 && B == 0) {
      printf("%lf\n", 1.0);
      continue;
    }
    if (B == 0) {
      printf("%lf\n", 1.0);
      continue;
    }
    if (A == 0) {
      printf("%lf\n", 0.5);
      continue;
    }
    double top = B * A;
    double bot = 2.0 * A * B;
    if (B * 4.0 <= A) {
      top += B * B * 2;
      top += (A - B * 4.0) * B;
    } else {
      top += A * A / 8.0;
    }
    printf("%.9lf\n", top / bot);
  }
  return 0;
}
