#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
int main() {
  int test;
  scanf("%d", &test);
  while (test-- > 0) {
    double a, b;
    scanf("%lf%lf", &a, &b);
    double total = 2. * (a + 0.) * (b + 0.);
    if (fabs(b) < eps && fabs(a) < eps) {
      printf("%.20lf\n", 1.);
      continue;
    }
    if (fabs(a) < eps) {
      printf("%.20lf\n", 0.5);
      continue;
    }
    if (fabs(b) < eps) {
      printf("%.20lf\n", 1.);
      continue;
    }
    double q = 0.;
    if (4 * b >= a) {
      q = (a + 0.) * (b + 0. - a / 4.);
      q += 0.5 * (a / 4.) * (a + 0.);
    } else {
      q = 2. * b * b;
    }
    printf("%.20lf\n", 1 - q / total);
  }
  return 0;
}
