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