#include <bits/stdc++.h>
int main() {
  int T, a, b;
  scanf("%d", &T);
  double p;
  while (T) {
    scanf("%d %d", &a, &b);
    p = 0;
    if (a == 0 && b == 0)
      p = 1;
    else if (b == 0)
      p = 1;
    else if (a == 0)
      p = .5;
    else if ((double)a / 4 < b) {
      p = .5 + ((double)a / (16 * b));
    } else {
      p = 1 - ((double)b / a);
    }
    printf("%lf\n", p);
    T--;
  }
  return 0;
}
