#include <bits/stdc++.h>
using namespace std;
signed main() {
  int T;
  cin >> T;
  double a, b;
  while (T--) {
    cin >> a >> b;
    if (b == 0) {
      printf("1\n");
      continue;
    };
    if (a == 0) {
      printf("0.5\n");
      continue;
    }
    double S;
    if (4 * b >= a)
      S = a * a / 8.0;
    else
      S = ((a - 4 * b + a) * b) / 2.0;
    S += a * b;
    printf("%.10lf\n", S / (a * b * 2.0));
  }
}
