#include <bits/stdc++.h>
int main() {
  int t;
  double a, b;
  double pos;
  scanf("%d", &t);
  while (t--) {
    scanf("%lf%lf", &a, &b);
    if (a > 0 && b > 0) {
      if (a < 4 * b)
        pos = (a * b + a * a / 8) / (2 * a * b);
      else
        pos = (2 * a * b - b * 2 * b) / (2 * a * b);
      printf("%.10lf\n", pos);
    } else if (b == 0) {
      printf("1\n");
    } else
      printf("0.5\n");
  }
  return 0;
}
