#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const double PI = acos(-1.0);
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    double a, b;
    scanf("%lf %lf", &a, &b);
    double second = a * b + a * a / 8.0;
    if (4.0 * b <= a) second -= (a / 4.0 - b) * (a - 4.0 * b) * 0.5;
    second /= 2.0 * a * b;
    if (b == 0)
      printf("1.0000000000000000000000\n");
    else if (a == 0)
      printf("0.500000000000000000000\n");
    else
      printf("%.20lf\n", second);
  }
  return 0;
}
