#include <bits/stdc++.h>
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
  std::cout.tie(0);
  std::cerr.tie(0);
  int64_t a, b, n;
  std::cin >> n;
  std::cout << std::fixed << std::setprecision(8);
  for (int it = 0; it < n; ++it) {
    std::cin >> a >> b;
    long double P;
    if (b == 0) {
      P = 1;
    } else if (a == 0) {
      P = 0.5;
    } else if (b * 4 < a) {
      P = 1 - static_cast<long double>(b) / a;
    } else {
      P = 0.5 + static_cast<long double>(a) / (16 * b);
    }
    std::cout << P << '\n';
  }
}
