#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  for (cin >> t; t--;) {
    long long a, b;
    cin >> a >> b;
    cout.setf(ios::fixed | ios::showpoint);
    cout.precision(7);
    if (b == 0) {
      cout << 1.0 << endl;
      continue;
    }
    if (a == 0) {
      cout << 0.5 << endl;
      continue;
    }
    double mx = min(a / 4., (double)b);
    cout << (a * b + a * mx - 2 * mx * mx) / (2. * a * b) << endl;
  }
  return 0;
}
