#include <bits/stdc++.h>
using namespace std;
const long long infl = 1e18 + 5;
long long int n, m, k, q, x, y, f, val, t = 1, i, j;
long long int ind = -1, cnt, sz, sm, ans, mx = -1, mn = infl;
long long int a, b;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  if (fopen("inp.txt", "r")) {
    freopen("myfile.txt", "w", stdout);
    freopen("inp.txt", "r", stdin);
  }
  cin >> t;
  double v1, ans;
  while (t--) {
    cin >> a >> b;
    if (b == 0) {
      cout << "1.0\n";
    } else if (a == 0) {
      cout << "0.50\n";
    } else if (a >= 4 * b) {
      v1 = 2 * a * b - 2 * b * b;
      ans = v1 / (2 * a * b);
      cout << fixed << setprecision(8) << ans << "\n";
    } else {
      v1 = a * b + a * a * (1 / 8.0);
      ans = v1 / (2 * a * b);
      cout << fixed << setprecision(8) << ans << "\n";
    }
  }
  return 0;
}
