#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a, b;
    cin >> a >> b;
    double da = a;
    double db = b;
    double ans = 1.0;
    if (b != 0) {
      if (a == 0)
        ans = 0.5;
      else {
        double all = 2.0 * da * db;
        double ok;
        if (da / 4.0 > db) {
          ok = 2.0 * da * db - 2.0 * db * db;
        } else
          ok = da * db + da * da / 8.0;
        ans = ok / all;
      }
    }
    printf("%.7lf\n", ans);
  }
  return 0;
}
