#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (b == 0)
      puts("1");
    else {
      if (a <= 4 * b)
        printf("%lf\n", (0.5 + a * 1.0 / (16 * b)));
      else
        printf("%lf\n", (1.0 - b * 1.0 / a));
    }
  }
  return 0;
}
