#include <bits/stdc++.h>
using namespace std;
int cmp(double x, double y) {
  if (fabs(x - y) < 1e-7) return 0;
  if (x < y) return -1;
  return 1;
}
float call(double a, double b) {
  double s1, s2;
  if (cmp(a / 4, b) <= 0) {
    s1 = b + a / 8;
  } else {
    double l1, l2, t1, t2;
    l1 = b * 4;
    t1 = b + b / 2;
    l2 = a - l1;
    t2 = 2 * b;
    s1 = (l1 * t1 + l2 * t2) / a;
  }
  return s1 / (2 * b);
}
int main() {
  int n, a, b;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a, &b);
    if (b == 0)
      printf("1\n");
    else if (a == 0)
      printf("0.5\n");
    else
      printf("%.9lf\n", call(a, b));
  }
}
