#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b;
  for (cin >> n; n--;) {
    cin >> a >> b;
    if (b == 0)
      cout << 1 << endl;
    else
      cout << setprecision(20)
           << (4 * b < a ? 1 - b * 1. / a : .5 + a / 16. / b) << endl;
  }
  return 0;
}
