#include <bits/stdc++.h>
using namespace std;
const int INF = 2000 * 1000 * 1000;
const long long LLINF = 1ll << 53;
template <class T>
void relaxmax(T& r, T v) {
  r = max(r, v);
}
template <class T>
void relaxmin(T& r, T v) {
  r = min(r, v);
}
int main() {
  int t;
  scanf("%d", &t);
  for (int i = 0; i < t; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (b == 0)
      printf("%.12f\n", 1.);
    else if (a == 0)
      printf("%.12f\n", 0.5);
    else {
      double x = min(a, 4 * b);
      double a1 = x * x / 8, a2 = (b - x / 4) * a;
      printf("%.12f\n", 1 - (a1 + a2) / 2 / b / a);
    }
  }
  return 0;
}
