#include <bits/stdc++.h>
using namespace std;
int main() {
  double a, b;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    if (b == 0) {
      cout << 1.000000 << endl;
      continue;
    }
    if (a == 0) {
      cout << 0.500000 << endl;
      continue;
    }
    if (b > a / 4) {
      printf("%.6lf\n", (b * a + a * a / 4 / 2) / a / b / 2);
    } else
      printf("%.6lf\n", (2 * b * a - b * 2 * b) / a / b / 2);
  }
  return 0;
}
