#include <bits/stdc++.h>
using namespace std;
const long long LINF = (long long)1e18;
const int INF = (int)1e9 + 7;
const int N = (int)1e6 + 7;
const double EPS = (double)1e-9;
const double PI = (double)3.14159265359;
const int MODULO[6] = {INF,        1000019677, 1000019393,
                       1000007521, 1000024073, 1000009667};
const int PF[5] = {77, 31, 98, 45, 67};
const int nx[4] = {0, 0, 1, -1};
const int ny[4] = {1, -1, 0, 0};
inline bool eq(const long double &a, const long double &b) {
  return fabs(a - b) < EPS;
}
int main() {
  srand(time(NULL));
  int tt;
  cin >> tt;
  while (tt--) {
    double a, b, k;
    cin >> a >> b;
    k = min(b * 4, a);
    if (a == 0 && b != 0)
      cout << 0.5 << endl;
    else if (b == 0)
      cout << 1.0 << endl;
    else
      cout << fixed << setprecision(9)
           << 0.5 + ((a - k) * b + (k * k) / 8) / (2 * b * a) << endl;
  }
  return 0;
}
