#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  double a, b, s, tot;
  cin >> T;
  while (T--) {
    cin >> a >> b;
    if (b == 0) {
      puts("1.0000000000");
      continue;
    }
    double tmp = a / 4;
    double ans = 0;
    ans += 1.0 / 2;
    if (tmp <= b) {
      s = tmp / 2 / b;
    } else {
      s = (a - 2 * b) / a;
    }
    ans += s / 2;
    printf("%.10lf\n", ans);
  }
}
