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