#include <bits/stdc++.h>
using namespace std;
double a, b;
int main() {
  int i, t;
  double sum, sumx, up, down, l;
  scanf("%d", &t);
  while (t--) {
    scanf("%lf%lf", &a, &b);
    if (b == 0) {
      printf("%.10f\n", 1.0);
      continue;
    }
    if (a == 0) {
      printf("%.10f\n", 0.5);
      continue;
    }
    b = b * 4;
    down = b;
    if (b > a) {
      up = b - a;
      l = a;
    } else {
      up = 0;
      l = b;
    }
    sumx = (down + up) * l / 2;
    sum = 2 * a * b;
    printf("%.10f\n", (sum - sumx) / sum);
  }
  return 0;
}
