#include <bits/stdc++.h>
using namespace std;
double work(double i, double j) {
  if (i == 0 && j == 0) return 1.0;
  if (i == 0) return 0.5;
  if (j == 0) return 1.0;
  double a = i, b = j;
  if (4 * b <= a) return (a * b - 2.0 * b * b) / (2.0 * a * b) + 0.5;
  return a / (b * 16.0) + 0.5;
}
int main() {
  int i, j, T;
  double a, b;
  scanf("%d", &T);
  while (T--) {
    scanf("%d%d", &i, &j);
    printf("%.10lf\n", work(i, j));
  }
  cin >> i;
  return 0;
}
