#include <bits/stdc++.h>
using namespace std;
long double a, b;
int main() {
  int T;
  cin >> T;
  while (T--) {
    cin >> a >> b;
    if (abs(a) <= 1.0e-6) {
      if (abs(b) <= 1.0e-6)
        cout << "1.0000000000" << endl;
      else
        cout << "0.5000000000" << endl;
      continue;
    }
    if (abs(b) <= 1.0e-6) {
      cout << "1.0000000000" << endl;
      continue;
    }
    if (a >= 4 * b)
      cout << fixed << setprecision(10) << (2 * b * a - b * b * 2) / (2 * b * a)
           << endl;
    else
      cout << fixed << setprecision(10) << (b * a + a * a / 8) / (2 * b * a)
           << endl;
  }
}
