#include <bits/stdc++.h>
using namespace std;
int main() {
  int tests;
  scanf("%d", &tests);
  for (int c = 0; c < tests; c++) {
    int a, b;
    scanf("%d%d", &a, &b);
    double res = 0.5;
    if (!b) {
      printf("1\n");
      continue;
    }
    if (!a) {
      printf("0.5\n");
      continue;
    }
    if (4 * b >= a)
      res += (a * (long long)a / 8.0) / (double)(a * (long long)2 * b);
    else
      res += (2 * b * (long long)b + (a - 4 * b) * (long long)b) /
             (double)(a * (long long)2 * b);
    printf("%.10lf\n", res);
  }
  return 0;
}
