#include <bits/stdc++.h>
using namespace std;
vector<long long int> v;
vector<long long int> v1;
vector<long long int> v2;
const long long int inf = 100000000000005;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    long double a, b, ar1, ar2;
    cin >> a >> b;
    if (b == 0) {
      cout << 1 << endl;
      continue;
    }
    if (a == 0) {
      cout << 0.5 << endl;
      continue;
    }
    ar1 = a * b * 2;
    if (a > 4 * b)
      ar2 = ar1 - ((b * 4 * b) / 2.0);
    else
      ar2 = (ar1 / 2.0) + ((a * a) / 8.0);
    cout << fixed << setprecision(10) << (ar2) / (ar1) << endl;
  }
  return 0;
}
