#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    double a, b;
    cin >> a >> b;
    if (a == 0.0 && b == 0.0) {
      cout << 1.0 << endl;
      continue;
    }
    if (a == 0.0) {
      cout << 0.5 << endl;
      continue;
    }
    if (b == 0.0) {
      cout << 1.0 << endl;
      continue;
    }
    double x = min(a / 4.0, b);
    double ans = 0.5 + ((a * x) / 2.0 - x * x) / (b * a);
    cout << ans << endl;
  }
  return 0;
}
