#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  int c = min(a, b), d = max(a, b);
  while (c) {
    int t = d % c;
    d = c;
    c = t;
  }
  return d;
}
int main() {
  int t;
  cin >> t;
  for (int(i) = (0); (i) < (t); ++(i)) {
    int a, b;
    cin >> a >> b;
    double r = 0.0;
    if (b == 0)
      r = 1.0;
    else if (a / 4.0 <= b) {
      r = a / 8.0;
      r = (r + b) / (2 * b);
    } else {
      r = 0.75 * 4 * b / a + 1.0 * (a - 4.0 * b) / a;
    }
    printf("%0.9lf\n", r);
  }
}
