#include <bits/stdc++.h>
using namespace std;
template <typename S, typename T>
ostream& operator<<(ostream& out, pair<S, T> const& p) {
  out << '(' << p.first << ", " << p.second << ')';
  return out;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T> const& v) {
  long long l = v.size();
  for (long long i = 0; i < l - 1; i++) out << v[i] << ' ';
  if (l > 0) out << v[l - 1];
  return out;
}
template <typename T>
void trace(const char* name, T&& arg1) {
  cout << name << " : " << arg1 << "\n";
}
template <typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  trace(comma + 1, args...);
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    long double a, b, temp;
    cin >> a >> b;
    if (b == 0) {
      printf("1.0000000\n");
      continue;
    }
    if (a == 0) {
      printf("0.50000000\n");
      continue;
    }
    if (4 * b < a) {
      long double ans = ((a - b) / a);
      printf("%0.9Lf\n", ans);
    } else {
      long double ans = ((b + a / 8) / (2 * b));
      printf("%0.9Lf\n", ans);
    }
  }
  return 0;
}
