#include <bits/stdc++.h>
using namespace std;
struct ver {
  int a;
  int b;
};
int main() {
  int n;
  cin >> n;
  ver *mass = new ver[n];
  for (int i = 0; i < n; i++) {
    cin >> mass[i].a >> mass[i].b;
  }
  for (int i = 0; i < n; i++) {
    if (mass[i].b == 0) {
      cout << "1" << endl;
      continue;
    }
    if (mass[i].a > mass[i].b * 4) {
      cout << 1.0 - (double)mass[i].b / mass[i].a << endl;
    } else
      cout << 0.5 + (double)mass[i].a / 16 / mass[i].b << endl;
  }
  return 0;
}
