#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (b == 0) {
      printf("1.0\n");
      continue;
    }
    if (a == 0) {
      printf("0.5\n");
      continue;
    }
    if (b * 4 <= a) {
      printf("%.10lf\n", (2.0 * a * b - 2.0 * b * b) / (2.0 * a * b));
    } else {
      printf("%.10lf\n", (1.0 * a * b + 0.125 * a * a) / (2.0 * a * b));
    }
  }
  return 0;
}
