#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  int t;
  cin >> t;
  while (t--) {
    double a, b;
    cin >> a >> b;
    cout << fixed << setprecision(15);
    if (b == 0) {
      cout << 1 << endl;
    } else if (a == 0) {
      cout << 0.5 << endl;
    } else if (a > b * 4) {
      cout << 1 - b / a << endl;
    } else {
      double remain = b - a / 4;
      cout << 1 - (b + remain) / (4 * b) << endl;
    }
  }
}
