#include <bits/stdc++.h>
using namespace std;
int i, t;
double a, b;
int main() {
  cin >> t;
  for (i = 0; i < t; i++) {
    cin >> a >> b;
    if (b == 0) {
      cout << 1 << endl;
      continue;
    }
    b *= 4;
    if (a > b) {
      cout << 1.0 - b / (4.0 * a) << endl;
      continue;
    }
    cout << (a / 2.0 + b) / (2.0 * b) << endl;
  }
  return 0;
}
