#include <bits/stdc++.h>
using namespace std;
int a, b;
double A, B;
void process() {
  scanf("%d%d", &a, &b);
  if (b == 0) {
    printf("%.8lf\n", 1.0);
    return;
  }
  A = a;
  B = b;
  if (a <= 4ll * b)
    printf("%.8lf\n", 0.5 + 0.0625 * A / B);
  else
    printf("%.8lf\n", 1.0 - B / A);
}
int main() {
  int test;
  scanf("%d", &test);
  for (; test; test--) process();
  return 0;
}
