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