#include <bits/stdc++.h>
int main() {
  int t;
  scanf("%d", &t);
  for (int i = 0; i < t; i++) {
    double a, b;
    scanf("%lf%lf", &a, &b);
    double prob = a * b;
    if (a == 0 && b == 0)
      prob = 1;
    else if (a == 0 && b != 0)
      prob = 0.5;
    else if (a != 0 && b == 0)
      prob = 1;
    else if (a / 4 <= b) {
      prob += a * a / 8;
      prob /= 2 * a * b;
    } else {
      double p = 4 * b;
      prob += (a - p) * b;
      prob += p * b / 2;
      prob /= 2 * a * b;
    }
    printf("%0.7lf\n", prob);
  }
}
