#include <bits/stdc++.h>
using namespace std;
int main() {
  cout.precision(12);
  int X;
  scanf("%d", &X);
  while (X--) {
    long long a, b;
    cin >> a >> b;
    long long total = 2 * a * b;
    if (a == 0) {
      if (b == 0)
        cout << 1 << endl;
      else
        cout << 0.5 << endl;
    } else if (b == 0) {
      cout << "1" << endl;
    } else if (a >= 4 * b) {
      long double res = (total - 2 * b * b) * 1.0 / total;
      cout << res << endl;
    } else {
      long double res = (total - a * b + a * a / 8.0) * 1.0 / total;
      cout << res << endl;
    }
  }
}
