#include <bits/stdc++.h>
using namespace std;
const long double pi = acos(-1.0);
const long double eps = 1e-9;
const int inf = 1e+9;
int n;
int main() {
  cin >> n;
  for (int i = 0; i < (n); ++i) {
    double a, b;
    cin >> a >> b;
    if (b != 0) {
      if (b >= 0.25 * a) {
        double p = (b + (a / 8.0)) / 2.0 / b;
        printf("%lf\n", p);
      } else {
        double p = (a - b) / a;
        printf("%lf\n", p);
      }
    } else
      printf("1\n");
  }
  return 0;
}
