#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, a, b;
  cin >> t;
  while (t--) {
    cin >> a >> b;
    double r = 0;
    if (b == 0)
      cout << 1.0;
    else if (a <= b * 4)
      cout << 0.5 + a / 16.0 / b;
    else
      cout << 0.5 + (a + a - 4 * b) / 4.0 / a;
    cout << endl;
  }
  return 0;
}
