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