#include <bits/stdc++.h>
long int a, b, p, q, n;
double s, ans;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a, &b);
    if (a == 0)
      if (b == 0)
        ans = 1;
      else
        ans = 0.5;
    else if (b > a / 4.0)
      ans = (b + b + a / 4.0) / 4 / b;
    else
      ans = 1 - (b * 1.0 / a);
    printf("%.10lf\n", ans);
  }
  return 0;
}
