#include <bits/stdc++.h>
using namespace std;
double a, b;
int main() {
  int w;
  cin >> w;
  while (w--) {
    cin >> a >> b;
    if (b - 0 < 0.0000000001) {
      printf("1.000000000000\n");
      continue;
    }
    if (a < 4 * b)
      printf("%.11lf\n", (2 * b + a / 4) / 4 / b);
    else
      printf("%.11lf\n", 1 - b / a);
  }
  return 0;
}
