#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  int t;
  cin >> t;
  while (t--) {
    double a, b;
    cin >> a >> b;
    if (a == 0 && b == 0) {
      cout << "1.000000\n";
      continue;
    }
    if (a == 0) {
      cout << "0.5000000\n";
      continue;
    }
    if (b == 0) {
      cout << "1.000000\n";
      continue;
    }
    if (a >= 4 * b) {
      double ans = 2 * a * b - 0.5 * b * (4.00 * b);
      ans /= (2 * a * b);
      cout << fixed << setprecision(6) << ans << endl;
    } else {
      double ans = a * b + 0.5 * a * (a / 4.00);
      ans /= (2 * a * b);
      cout << fixed << setprecision(6) << ans << endl;
    }
  }
  return 0;
}
