#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long t;
  cin >> t;
  while (t--) {
    cout << fixed << setprecision(10);
    long double a, b;
    cin >> a >> b;
    if (b == 0) {
      cout << 1;
    } else if (a == 0) {
      cout << 0.5;
    } else if (4 * b >= a) {
      cout << (a * a / 8 + a * b) / (2 * a * b);
    } else {
      cout << (2 * a * b - 2 * b * b) / (2 * a * b);
    }
    cout << endl;
  }
}
