#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, a, b;
  cin >> t;
  while (t-- > 0) {
    cin >> a >> b;
    double ans;
    if (b == 0) {
      cout << 1 << endl;
      continue;
    } else if (a < 0.0000001) {
      cout << 0.5 << endl;
      continue;
    }
    if (a < 4 * b) {
      ans = (double)(a + 8 * b) / 16 / b;
    } else {
      ans = (double)(a - b) / (double)a;
    }
    cout << fixed << setprecision(9) << ans << endl;
  }
  return 0;
}
