#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    if (a == 0 && b != 0) {
      cout << 0.5 << "\n";
      continue;
    }
    if (b == 0) {
      cout << "1\n";
      continue;
    }
    long long total = a * (2 * b);
    long double need = total - 2 * b * b;
    if (4 * b > a) need = a * b + (a * a) / 8.0;
    cout << fixed << setprecision(12) << (need / (long double)total) << "\n";
  }
}
