#include <bits/stdc++.h>
using namespace std;
int sign(double x) {
  if (x > 1e-10)
    return 1;
  else if (x < 1e-10)
    return -1;
  return 0;
}
double cal(double a, double b) {
  if (b < 1e-10)
    return 1;
  else if (a < 1e-10)
    return 0.5;
  else {
    double x = a / 4;
    int s = sign(x - b);
    if (s >= 0)
      return (a * b * 2 - b * b * 2) / (a * b * 2);
    else
      return ((x + b + b) * a / 2) / (a * b * 2);
  }
}
int main() {
  int t;
  double a, b;
  cin >> t;
  while (t--) {
    scanf("%lf%lf", &a, &b);
    printf("%.10f\n", cal(a, b));
  }
  return 0;
}
