#include <bits/stdc++.h>
using namespace std;
int main(void) {
  double a, b, ret;
  int n, i;
  long long tmp;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a >> b;
    tmp = a * b * 2;
    if (a == 0 && b == 0) {
      ret = 1;
    } else if (a == 0) {
      ret = 0.5;
    } else if (b == 0) {
      ret = 1;
    } else if (a <= b * 4) {
      ret = (b + (b + (double)a / 4)) * a / (2 * tmp);
    } else {
      ret = 1 - (double)(b * b * 2) / tmp;
    }
    cout << ret << endl;
  }
  return 0;
}
