#include <bits/stdc++.h>
using namespace std;
double solve(double a, double b) {
  if (b == 0) return 1.0;
  if (a == 0) return 0.5;
  if (4.0 * b > a) {
    return (0.5 + a / b / 16.0);
  } else
    return (1.0 - b / a);
}
int main(int argc, char* argv[]) {
  int T;
  cin >> T;
  while (T--) {
    double a, b;
    cin >> a >> b;
    cout << solve(a, b) << endl;
  }
  return 0;
}
