#include <bits/stdc++.h>
using namespace std;
int main() {
  int l, t, a, b;
  double ans;
  scanf("%d", &t);
  for (l = 0; l < t; l++) {
    scanf("%d%d", &a, &b);
    if (b == 0)
      ans = 1;
    else if (a > b * 4) {
      ans = 0.5 + ((a - b * 4) * 1.0 / a + 0.5 * b * 4 / a) / 2;
    } else
      ans = 1.0 * a / 4 / b / 4 + 0.5;
    printf("%.10lf\n", ans);
  }
  return 0;
}
