#include <bits/stdc++.h>
using namespace std;
double t, a, b;
int main() {
  cin >> t;
  while (t--) {
    cin >> a >> b;
    if (!a && !b)
      cout << "1\n";
    else if (a <= b * 4)
      cout << fixed << setprecision(9) << a / 4 / b / 4 + 0.5 << endl;
    else
      cout << fixed << setprecision(9) << 1 - b / a << endl;
  }
}
