#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll md = 1000000007;
ll exp(ll a, ll b) {
  ll r = 1ll;
  while (b > 0) {
    if (b & 1) {
      r = r * (a % md);
      r = (r + md) % md;
    }
    b >>= 1;
    a = (a % md) * (a % md);
    a = (a + md) % md;
  }
  return (r + md) % md;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
T Min(T a, T b) {
  if (a < b) return a;
  return b;
}
template <class T>
T Max(T a, T b) {
  if (a > b) return a;
  return b;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    cout << fixed << setprecision(12);
    if (b == 0) {
      cout << "1\n";
      continue;
    } else if (a == 0) {
      cout << "0.5\n";
      continue;
    }
    double d = 1.0;
    double x = 4 * b, y = a * d / 4, total = 2 * b * a, fav;
    if (y < b) {
      fav = a * b + y * a / 2;
    } else {
      fav = total - b * x / 2;
    }
    double ans = fav / total;
    cout << ans;
    cout << '\n';
  }
  return 0;
}
