#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    if (a == 0 && b == 0) {
      cout << 1 << '\n';
      continue;
    }
    if (a == 0) {
      cout << 0.5 << '\n';
      continue;
    }
    if (b == 0) {
      cout << 1 << '\n';
      continue;
    }
    double slope = 1.0 * b / a;
    double ans = a * b;
    if (slope > .25)
      ans += a * a / 8.0;
    else
      ans += (a * b - 2.0 * b * b);
    cout << fixed << setprecision(10);
    cout << ans / (2.0 * a * b) << '\n';
  }
}
