#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
int main() {
  int cas;
  scanf("%d", &cas);
  while (cas--) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a == 0 && b == 0) {
      puts("1.0");
    } else if (a == 0) {
      puts("0.5");
    } else if (b == 0) {
      puts("1.0");
    } else {
      double p = a, q = b, ans;
      if (4 * q >= p) {
        ans = (2 * q - p / 4) * p / 2.0;
      } else {
        ans = 4.0 * q * q / 2.0;
      }
      printf("%.12f\n", 1 - ans / (2 * p * q));
    }
  }
  return 0;
}
