#include <bits/stdc++.h>
using namespace std;
const int MAX_SIZE = 10000;
void solve() {
  int t;
  long long a, b;
  vector<pair<long, long> > pis;
  cin >> t;
  for (int i = 0; i < t; i++) {
    pair<long, long> p;
    cin >> p.first >> p.second;
    pis.push_back(p);
  }
  for (int i = 0; i < t; i++) {
    a = pis[i].first;
    b = pis[i].second;
    if (b == 0)
      printf("%.10f\n", 1.0);
    else if (a == 0)
      printf("%.10f\n", 0.5);
    else {
      if (4 * b <= a) {
        printf("%.10f\n", (double)(2 * a * b - 2 * b * b) / (2 * b * a));
      } else {
        printf("%.10f\n", (double)(a * b + ((double)a * a) / 8) / (2 * b * a));
      }
    }
  }
}
int main() {
  solve();
  return 0;
}
