#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000000 + 7;
const long long int N = 10000000 + 6;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  cout << setprecision(10) << fixed;
  while (t--) {
    double a, b;
    cin >> a >> b;
    if (a == 0 && b == 0) {
      cout << 1.0000 << '\n';
      continue;
    }
    if (a == 0) {
      cout << 0.5000 << '\n';
      continue;
    }
    if (b == 0) {
      cout << 1 << '\n';
      continue;
    }
    double g = min(4 * b, a);
    cout << ((g * b + (g * g) / 8) / (2 * a * b)) + ((a - g) / a) << '\n';
  }
  return 0;
}
