#include <bits/stdc++.h>
using namespace std;
using namespace std;
long double a, b, c, d, e, f, k, probability, t, a1, a2, a3, base1 = 0.5, base2;
long double area1, area2;
int main() {
  cin >> t;
  for (int i = 0; i < t; i++) {
    cin >> a >> b;
    if (b == 0) {
      cout << 1 << endl;
      continue;
    }
    if (a == 0) {
      cout << 0.5 << endl;
      continue;
    }
    b = b * 8;
    a1 = min(a, b / 2);
    base2 = ((b / 2) + a1) / b;
    area1 = ((base1 + base2) * a1) / 2;
    if (a1 == a) {
      probability = area1 / a;
      cout << setprecision(10) << probability << endl;
    } else {
      area2 = a - (b / 2);
      probability = (area1 + area2) / a;
      cout << setprecision(10) << probability << endl;
    }
  }
}
