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