#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  scanf("%d", &T);
  ;
  for (int(t) = 0; t < (int)T; t++) {
    long long a;
    long long b;
    cin >> a >> b;
    if (b == 0)
      printf("1\n");
    else if (a == 0) {
      printf("0.5\n");
    } else if (4 * b <= a) {
      double area = 2 * b;
      area *= b;
      double res = ((double)area) / (2 * b * a);
      printf("%.8lf\n", 1 - res);
    } else {
      double area = a / ((double)8);
      area *= a;
      area = a * b - area;
      double res = 1 - area / (2 * b * a);
      printf("%.8lf\n", res);
    }
  }
}
