#include <bits/stdc++.h>
using namespace std;
int main() {
  int nCase;
  scanf("%d", &nCase);
  while (nCase--) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a == 0) {
      if (b == 0)
        printf("1\n");
      else
        printf("0.5\n");
      continue;
    }
    if (b == 0) {
      printf("1\n");
      continue;
    }
    b *= 4;
    if (a >= b)
      printf("%.6f\n", (0.5 * (a - b + a) * b + 1.0 * a * b) / (2.0 * b * a));
    else
      printf("%.6f\n", (1.0 * a * b + 0.5 * a * a) / (2.0 * b * a));
  }
  return 0;
}
