#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  int t;
  cin >> t;
  cout << fixed << setprecision(10);
  while (t--) {
    int a, b;
    cin >> a >> b;
    auto area = 2ll * a * b;
    auto ans = 0.0;
    if (a < 4 * b) {
      ans = (b - 0.125 * a) * a;
    } else {
      ans = 2.0 * b * b;
    }
    if (a == 0)
      ans = b ? 0.5 : 1.0;
    else if (b == 0)
      ans = 1.0;
    else
      ans = 1.0 - ans / area;
    cout << ans << '\n';
  }
}
