#include <bits/stdc++.h>
using namespace std;
int INP, AM, REACHEOF;
const int BUFSIZE = (1 << 12) + 17;
char BUF[BUFSIZE + 1], *inp = BUF;
int main() {
  ios ::sync_with_stdio(false);
  int ntest;
  cin >> ntest;
  while (ntest--) {
    long long a, b;
    cin >> a >> b;
    long double res = 0.5;
    long double now = 0.0;
    if (a == 0 && b == 0)
      now = 1.0;
    else if (a == 0)
      now = 0.0;
    else if (b == 0)
      now = 1.0;
    else if (a == 4 * b)
      now += 0.5;
    else if (a < 4 * b) {
      now += a / 8.0 / (long double)b;
    } else {
      now += 1 - 2 * b / (long double)a;
    }
    res += now * 0.5;
    cout << (fixed) << setprecision(9) << res << endl;
  }
  return 0;
}
