#include <bits/stdc++.h>
int main() {
  int aa, bb;
  int n, i;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    double a, b;
    scanf("%d %d\n", &aa, &bb);
    a = aa;
    b = bb;
    if (b == 0)
      printf("1.0000\n");
    else if (a == 0)
      printf("0.5000\n");
    else if (a >= 4 * b)
      printf("%lf\n", 1 - b * 2 * b / (2 * a * b));
    else {
      printf("%lf\n",
             1 - ((a * (a / 4)) / (a * b * 4) + a * (b - a / 4) / (2 * a * b)));
    }
  }
  return 0;
}
