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