#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long double a, b;
    cin >> a >> b;
    if (a == 0 && b == 0) {
      cout << 1 << endl;
      continue;
    }
    if (a == 0) {
      cout << 0.5 << endl;
      continue;
    }
    if (b == 0) {
      cout << 1 << endl;
      continue;
    }
    if (a / 4 <= b)
      cout << fixed << setprecision(10) << (a * b + a * a / 8) / (2 * a * b)
           << endl;
    else {
      long double part1 = 2 * b * b;
      long double part2 = (a - 4 * b) * b;
      cout << fixed << setprecision(10) << (a * b + part1 + part2) / (2 * a * b)
           << endl;
    }
  }
  return 0;
}
