#include <bits/stdc++.h>
using namespace std;
int t;
long double a, b, lf;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> t;
  while (t--) {
    cin >> a >> b;
    if (a == 0 || b == 0) {
      if (b == 0)
        printf("1\n");
      else
        printf("0.5\n");
      continue;
    }
    if (b == 0 || a / b >= 4) {
      lf = a * b * 2 - b * b * 2;
    } else {
      lf = a * b * 2 - a * a / 8 - a * (b - a / 4);
    }
    printf("%.6Lf\n", lf / (a * b * 2));
  }
  return 0;
}
