#include <bits/stdc++.h>
using namespace std;
inline void pisz(int n) { printf("%d\n", n); }
template <typename T, typename TT>
ostream& operator<<(ostream& s, pair<T, TT> t) {
  return s << "(" << t.first << "," << t.second << ")";
}
template <typename T>
ostream& operator<<(ostream& s, vector<T> t) {
  for (int(i) = 0; (i) < (t.size()); ++(i)) s << t[i] << " ";
  return s;
}
int main() {
  ios_base::sync_with_stdio(0);
  int te;
  cin >> te;
  while (te--) {
    int a, b;
    cin >> a >> b;
    double wyn;
    if (a == 0) {
      if (b == 0)
        wyn = 1;
      else
        wyn = 0.5;
    } else if (a < 4 * b) {
      wyn = 0.5 + (double)a / (16 * b);
    } else {
      wyn = 1.0 - (double)b / a;
    }
    cout << setprecision(10) << fixed << wyn << "\n";
  }
}
