#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  double a, b;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    if (b == 0)
      cout << 1 << endl;
    else if (a <= 4 * b)
      printf("%lf \n", (0.5 + double(a) / 16 / b));
    else
      printf("%lf \n", (1 - double(b) / a));
  }
  return 0;
}
