#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  double a, b;
  cin >> T;
  long long num, den;
  while (T--) {
    cin >> a >> b;
    double res;
    if (b == 0)
      res = 1;
    else if (4 * b < a)
      res = 1 - b / a;
    else
      res = 0.5 + a / 16 / b;
    printf("%.8f\n", res);
  }
}
