#include <bits/stdc++.h>
using namespace std;
int main() {
  double a = 0, b = 0;
  int t = 0;
  vector<double> v;
  cin >> t;
  while (t--) {
    cin >> a >> b;
    if (a == 0 && b == 0)
      v.push_back(1.0);
    else if (a == 0)
      v.push_back(0.5);
    else if (b == 0)
      v.push_back(1.0);
    else if (a >= 4 * b)
      v.push_back(0.5 + ((a - 4 * b) / a + (4 * b / a) * 0.5) * 0.5);
    else
      v.push_back(0.5 + ((a / (4 * b)) * 0.5) * 0.5);
  }
  for (int i = 0; i < (int)v.size(); i++)
    cout << setprecision(8) << fixed << v[i] << "\n";
  return 0;
}
