#include <bits/stdc++.h>
using namespace std;
int main() {
  double a, b;
  int t;
  cin >> t;
  while (t--) {
    cin >> a >> b;
    if (not b)
      cout << "1.000000\n";
    else if (not a)
      cout << "0.500000\n";
    else if (a <= 4 * b)
      printf("%.6lf\n", 0.5 + a / (16 * b));
    else
      printf("%.6lf\n", 1 - b / a);
  }
  return 0;
}
