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