#include <bits/stdc++.h>
using namespace std;
int main() {
  double test, a, b;
  cin >> test;
  while (test--) {
    cin >> a >> b;
    if (a == 0.0 && b != 0.0)
      cout << 0.5 << endl;
    else if (b == 0)
      cout << 1 << endl;
    else if (a > 4 * b)
      printf("%.10lf\n", (2.0 * a * b - 2.0 * b * b) / (2.0 * a * b));
    else
      printf("%.10lf\n", (a * b + a * a * 0.125) / (2.0 * a * b));
  }
  return 0;
}
