#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t, a, b;
  double x, s;
  cin >> t;
  while (t--) {
    cin >> a >> b;
    if (b == 0) {
      cout << 1.0 << endl;
      continue;
    } else if (a == 0) {
      cout << 0.5 << endl;
      continue;
    }
    x = 4.0 * b;
    if (x <= a)
      s = x * b / 2.0;
    else {
      x = a / 4.0;
      s = (b - x + b) * a / 2.0;
    }
    printf("%.8f\n", 1 - s / (b * a * 2.));
  }
  return 0;
}
