#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(false);
  int t;
  cout << fixed;
  cout << setprecision(12);
  cin >> t;
  while (t--) {
    double a, b;
    cin >> a >> b;
    if (b == 0) {
      cout << 1 << "\n";
      continue;
    }
    if (a == 0) {
      cout << 0.5 << "\n";
      continue;
    }
    double den = a * ((b)*2.0);
    double num = a * b;
    if (a / 4.0 > b) {
      num += 0.5 * (b * 4) * (b);
      num += (a - b * 4) * b;
    } else {
      num += 0.5 * a / 4.0 * a;
    }
    cout << 1.0 * num / den << "\n";
  }
}
