#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long double a, b;
    cin >> a >> b;
    if (b == 0) {
      printf("1\n");
      continue;
    }
    long double ans = 0.5;
    if (a > b * 4)
      ans += 0.5 - b / a;
    else
      ans += a / 16 / b;
    printf("%.10lf\n", double(ans));
  }
  return 0;
}
