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