#include <bits/stdc++.h>
using namespace std;
const int MAX = 100, INF = 1 << 30;
int main() {
  int n;
  double a, b, t;
  cin >> n;
  while (n--) {
    cin >> a >> b;
    if (!b) {
      t = 1;
      goto ans;
    }
    if (!a) {
      t = 0.5;
      goto ans;
    }
    if (4 * b > a)
      t = ((2 * b * a) - ((b - a / 4) + b) * a / 2) / (2 * b * a);
    else
      t = ((2 * b * a) - (b * 4 * b) / 2) / (2 * b * a);
  ans:
    printf("%.10lf\n", t);
  }
  return 0;
}
