#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  scanf("%d", &T);
  double p, q;
  while (T--) {
    scanf("%lf%lf", &p, &q);
    if (p == 0) {
      if (q == 0)
        printf("1.0000\n");
      else
        printf("0.500\n");
      continue;
    }
    if (q == 0)
      printf("1.0000\n");
    else if (4 * q > p)
      printf("%.11f\n", (p * p * 0.125 + p * q) / (2 * p * q));
    else
      printf("%.11f\n", (p * q - q * q * 2 + p * q) / (2 * p * q));
  }
  return 0;
}
