#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    double p, q;
    cin >> p >> q;
    if (p == 0 && q == 0)
      cout << 1.0 << endl;
    else if (p == 0)
      cout << 0.5 << endl;
    else if (q == 0)
      cout << 1.0 << endl;
    else if (p < 4.0 * q)
      cout << (8.0 * q + p) / (16 * q) << endl;
    else
      cout << (p - q) / p << endl;
  }
  return 0;
}
