#include <bits/stdc++.h>
using namespace std;
double solve(int a, int b) {
  if (b == 0) return 1;
  if (a == 0) return .5;
  if (a < 4 * b)
    return double(8 * b + a) / b / 16;
  else
    return double(a - b) / a;
}
int main() {
  int t, a, b;
  cin >> t;
  while (t--) {
    cin >> a >> b;
    cout << setprecision(10) << solve(a, b) << endl;
  }
  return 0;
}
