#include <bits/stdc++.h>
using namespace std;
int main() {
  double a, b;
  int N;
  cin >> N;
  while (N-- > 0) {
    cin >> a >> b;
    if (b == 0) {
      cout << 1 << endl;
      continue;
    }
    if (a == 0) {
      cout << 0.5 << endl;
      continue;
    }
    double y = 0.25 * a;
    double upper = 0;
    if (y <= b) {
      upper = 0.5 * a * y;
    } else {
      upper = a * b - 2 * b * b;
    }
    cout << fixed << setprecision(8) << (upper + a * b) / (2 * a * b) << endl;
  }
  return 0;
}
