#include <bits/stdc++.h>
using namespace std;
double a, b;
int main() {
  int T, ca = 0;
  for (scanf("%d", &T); T; T--) {
    scanf("%lf%lf", &a, &b);
    if (b < 1e-8) {
      printf("1.000000000\n");
      continue;
    }
    if (a < 1e-8) {
      printf("0.500000000\n");
      continue;
    }
    b *= 4;
    double area = b * b / 2;
    if (b > a) area = a * (b + (b - a)) / 2;
    printf("%.10f\n", 1 - area / (a * 2 * b));
  }
}
