#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 3;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long double fct = 16.0;
  long long t;
  cin >> t;
  while (t--) {
    long double a, b;
    cin >> a >> b;
    if (b == 0) {
      cout << (long double)1 << "\n";
      continue;
    }
    if (a == 0) {
      cout << (long double)0.5 << "\n";
      continue;
    }
    long double ans = 0;
    if (a <= 4 * b) {
      ans = a;
      ans /= b;
      ans /= fct;
      ans += 0.5;
    } else {
      ans = 1;
      ans -= (b / a);
    }
    cout << fixed << setprecision(30) << ans << "\n";
  }
}
