#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(false);
  int tst;
  cin >> tst;
  cout.precision(10);
  cout.setf(ios::fixed);
  while (tst--) {
    int a, b;
    cin >> a >> b;
    if (a == 0 || b == 0) {
      if (b == 0)
        cout << 1.0 << "\n";
      else if (a == 0)
        cout << .5 << "\n";
      continue;
    }
    double u = min(1.0 * b, 1.0 * a / 4.0);
    double ans = (1.0 * a * u - 2.0 * u * u + 1.0 * b * a) / (2.0 * b * a);
    cout << (ans) << "\n";
  }
  return 0;
}
