#include <bits/stdc++.h>
using namespace std;
int main() {
  double a, b, x, temp;
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    cin >> a >> b;
    if (b == 0 || (b == 0 && a == 0))
      cout << 1 << endl;
    else if (a == 0)
      cout << 0.5 << endl;
    else {
      x = ((4 * b) < (a) ? (4 * b) : (a));
      if (x == a)
        temp = (a * b) + ((a * (a / 4)) / 2);
      else
        temp = (a * b) + ((a * b) - (x * b) / 2);
      cout << temp / (2 * a * b) << endl;
    }
  }
}
