#include <bits/stdc++.h>
using namespace std;
void solve();
int main() {
  int t;
  cin >> t;
  while (t--) solve();
}
long long a, b;
void solve() {
  cin >> a >> b;
  long long all = a * 2 * b;
  if (a == 0) {
    if (b != 0)
      cout << "0.5000000" << endl;
    else
      cout << "1" << endl;
    return;
  }
  if (b == 0) {
    cout << "1" << endl;
    return;
  }
  long double good = 0;
  good += (long double)a * b;
  long double p;
  if (a < 4 * b) {
    long double r = (long double)a / 4;
    good += (long double)r * a / 2;
  } else
    good += (long double)a * b - b * 2 * b;
  p = (long double)good / all;
  printf("%.10Lf\n", p);
}
