#include <bits/stdc++.h>
using namespace std;
double eps = 1e-7;
int main() {
  int t;
  double a, b, ans;
  scanf("%d", &t);
  while (t--) {
    scanf("%lf%lf", &a, &b);
    ans = 0.50000000;
    if (b < eps) {
      printf("%lf\n", 1.0);
      continue;
    }
    if (a < eps) {
      printf("%lf\n", 0.5);
      continue;
    }
    if (a / b - 4.0 < -eps) {
      ans += 0.5 * (a * a / 8.0) / (a * b);
    } else {
      ans += 0.5 * (a * b - b * 2.0 * b) / (a * b);
    }
    printf("%lf\n", ans);
  }
  return 0;
}
