#include <bits/stdc++.h>
using namespace std;
int n;
double a, b;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  cout << fixed << setprecision(9);
  while (n--) {
    cin >> a >> b;
    if (a == 0 && b == 0)
      cout << 1 << endl;
    else if (a / 4 < b)
      cout << a / 4 / 2 / 2 / b + 0.5 << endl;
    else
      cout << 1 - 4 * b / 4 / a << endl;
  }
  return 0;
}
