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