#include <bits/stdc++.h>
long long int mod = 1000000007;
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cout.setf(ios::fixed);
  cout << setprecision(10);
  cin >> t;
  while (t--) {
    long double a, b;
    cin >> a >> b;
    long double total = 2 * a * b;
    if (b == 0) {
      cout << "1.0\n";
      continue;
    }
    if (a == 0) {
      cout << "0.5\n";
      continue;
    }
    long double add = a / 4;
    long double top = 0;
    if (add <= b) {
      top += (0.5 * a * add);
      top += (a * b);
    } else {
      top += (0.5 * a * add);
      top += (a * b);
      long double diff = a - 4 * b;
      long double diff2 = add - b;
      top -= (0.5 * diff2 * diff);
    }
    long double ans = top / total;
    cout << ans << "\n";
  }
  return 0;
}
