#include <bits/stdc++.h>
using namespace std;
int const inf = 1e9 + 7, N = 3e5 + 6;
long long dp[N][20], a[N], b[N], n, k, x, m, x1, x2;
bool us[N];
string second, t;
vector<long long> v[100005];
map<string, long long> mp;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> x;
  for (int z = 0; z < x; z++) {
    double c, d, ans = 0.5;
    cin >> c >> d;
    if (d == 0)
      ans = 1;
    else if (4 * d < c)
      ans += (0.5 - d / c);
    else
      ans += c / 16 / d;
    cout << fixed << setprecision(8) << ans << endl;
  }
  return 0;
}
