#include <bits/stdc++.h>
using namespace std;
int T;
double A, B;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> T;
  for (int i = 0; i < T; i++) {
    cin >> A >> B;
    double BB = 4 * B;
    double ans;
    if (BB > A) {
      ans = (A * BB + A * A / 2.0) / (2 * A * BB);
    } else {
      ans = ((2 * A - BB) / 2 * BB + A * BB) / (2 * A * BB);
    }
    if (B == 0.0)
      ans = 1.0;
    else if (A == 0.0)
      ans = 0.5;
    cout << fixed << setprecision(10) << ans << endl;
  }
  return 0;
}
