#include <bits/stdc++.h>
using namespace std;
double a, b;
double cal() {
  if (fabs(b) < 1e-6) return 1.0;
  if (fabs(a) < 1e-6) return 0.5;
  if (4.0 * b >= a) return 0.5 + a / b / 16.0;
  return 1.0 - b / a;
}
int main() {
  int n;
  while (~scanf("%d", &n)) {
    while (n--) {
      scanf("%lf%lf", &a, &b);
      printf("%.9f\n", cal());
    }
  }
}
