#include <bits/stdc++.h>
using namespace std;
bool comp(pair<int, int> a, pair<int, int> b) {
  return (a.first == b.first) ? a.second < b.second : a.first < b.first;
}
long long int modInverse(long long int a, long long int n) {
  long long int m = n;
  long long int y = 0, x = 1;
  while (a > 1) {
    long long int q = a / m;
    long long int t = m;
    m = a % m, a = t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0) x += n;
  return x;
}
long long int binpow(long long int a, long long int p) {
  if (p == 0) return 1;
  long long int ret = binpow(a, p / 2);
  ret *= ret;
  ret %= 1000000007;
  if (p % 2) {
    ret *= a;
    ret %= 1000000007;
  }
  return ret;
}
int fact[400005];
int ncr(int n, int r) {
  int res1 = fact[n];
  res1 = fact[n] * fact[n - r] * fact[r];
  return res1 % 3;
}
const int N = 2e5 + 5;
int lp[N + 1];
vector<int> pr;
void sieve() {
  for (int i = 2; i <= N; ++i) {
    if (lp[i] == 0) {
      lp[i] = i;
      pr.push_back(i);
    }
    for (int j = 0; j < (int)pr.size() && pr[j] <= lp[i] && i * pr[j] <= N; ++j)
      lp[i * pr[j]] = pr[j];
  }
}
void solve() {
  cout << std::setprecision(9) << std::fixed;
  ;
  double a, b;
  double ans = 0.5;
  cin >> a >> b;
  if (b == 0) {
    cout << 1 << '\n';
    return;
  }
  if (a == 0) {
    cout << ans << '\n';
    return;
  }
  double nb, na, area, tot;
  tot = a * b * 2;
  nb = a / 4;
  na = 4 * b;
  if (nb <= b) {
    area = (nb * a) / 2;
  } else {
    area = (na * b) / 2;
    area += (a - na) * b;
  }
  area /= tot;
  ans += area;
  cout << ans << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int t;
  cin >> t;
  for (int tc = 0; tc < t; tc++) {
    solve();
  }
}
