#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  double a, b;
  cin >> t;
  cout << fixed << setprecision(10);
  while (t--) {
    cin >> a >> b;
    if (b == 0) {
      cout << "1\n";
      continue;
    }
    if (a == 0) {
      cout << "0.5000000000\n";
      continue;
    }
    if (a / 4 > b)
      cout << 1 - (2 * b * b) / (2 * a * b);
    else
      cout << 1 - (a * b - a * a / 8) / (2 * a * b);
    cout << "\n";
  }
}
