#include <bits/stdc++.h>
using namespace std;
int main() {
  int tc;
  scanf("%d", &tc);
  while (tc--) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a != 0 && b != 0) {
      double s = 2.0 * a * b;
      double s1 = (double)a * b;
      if (4 * b <= a)
        s1 = 2 * s1 - 2.0 * b * b;
      else
        s1 += 0.125 * a * a;
      printf("%.10f\n", s1 / s);
    } else if (a == 0 && b != 0) {
      printf("0.5000000000\n");
    } else if (a != 0 && b == 0) {
      printf("1.0000000000\n");
    } else {
      printf("1.0000000000\n");
    }
  }
  return 0;
}
