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