#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  double a, b;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    cin >> a >> b;
    if (a && b) {
      if (a / 4 > b)
        printf("%.8f\n", (a * b - 2 * b * b + b * a) / (2 * b * a));
      else
        printf("%.8f\n", (a * a / 8 + b * a) / (2 * b * a));
    } else if (a == 0 && b)
      printf("%.8f\n", 0.5);
    else
      printf("%.8f\n", 1.0);
  }
  return 0;
}
