#include <bits/stdc++.h>
using namespace std;
double doMagic(double a, double b) {
  double res = 0.5;
  if (a <= 4.0 * b)
    res += (a) / (16.0 * b);
  else
    res += (a - 2.0 * b) / (2.0 * a);
  return res;
}
int main() {
  int t;
  scanf("%d\n", &t);
  for (int i = 0; i < t; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    if (b == 0) {
      printf("%s", "1\n");
      continue;
    }
    if (a == 0) {
      printf("%s", "0.5\n");
      continue;
    }
    printf("%lf\n", doMagic(a, b));
  }
exit:
  return (0);
}
