#include <bits/stdc++.h>
using namespace std;
const long long N = 105;
double a, b;
long long solve() {
  cin >> a >> b;
  if (b == 0.0)
    cout << 1.0 << '\n';
  else if (a == 0.0) {
    cout << 0.5 << '\n';
  } else {
    double l;
    if (4.0 * b <= a)
      l = b;
    else
      l = a / 4.0;
    double ans = (l / (2.0 * b)) - ((l * l * 1.0) / (a * b * 1.0));
    ans = ans + 0.5;
    cout << setprecision(10) << ans << '\n';
  }
  return 0;
}
signed main() {
  long long t;
  ios_base::sync_with_stdio(false);
  cin >> t;
  while (t--) solve();
  return 0;
}
