#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-12;
int t;
double a, b, c;
int main() {
  scanf("%d", &t);
  for (int i = 0; i < t; i++) {
    scanf("%lf%lf", &a, &b);
    if (fabs(b) <= eps)
      printf("%.12lf\n", 1.0);
    else if (fabs(a) <= eps)
      printf("%.12lf\n", 0.5);
    else {
      c = 0.5;
      if (4 * b >= a - eps)
        c += (a / (16 * b));
      else
        c += (a - 2 * b) / (2 * a);
      printf("%.12lf\n", c);
    }
  }
  return 0;
}
