#include <bits/stdc++.h>
using namespace std;
int dblcmp(double x) {
  if (x > -1e-10 && x < 1e-10) return 0;
  return x > 0 ? 1 : -1;
}
int main() {
  int t;
  double a, b;
  scanf("%d", &t);
  while (t--) {
    scanf("%lf %lf", &a, &b);
    if (!dblcmp(b))
      printf("1\n");
    else if (!dblcmp(a))
      printf("0.5\n");
    else {
      if (dblcmp(a / 4 - b) <= 0)
        printf("%lf\n", (2 * b + a / 4) / (4 * b));
      else
        printf("%lf\n", (a - b) / a);
    }
  }
  return 0;
}
