#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  double a, b, ans;
  cin >> t;
  cout << setprecision(10);
  for (int i = 0; i < t; i++) {
    cin >> a >> b;
    if (b == 0)
      ans = 1.0;
    else if (a == 0)
      ans = 0.5;
    else if (4 * b < a)
      ans = 1.0 - b / a;
    else
      ans = 0.5 + a / (16.0 * b);
    cout << ans << endl;
  }
}
