#include <bits/stdc++.h>
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    double a, b;
    scanf("%lf %lf", &a, &b);
    double x, y;
    if (b >= (a / 4)) {
      x = (b + a / 8) * a;
      y = a * 2 * b;
    } else if (b < (a / 4)) {
      x = a * b + (2 * a - 4 * b) * b / 2;
      y = a * 2 * b;
    }
    if (b == 0)
      printf("1\n");
    else if (a == 0)
      printf("0.5\n");
    else
      printf("%.10lf\n", x / y);
  }
  return 0;
}
