#include <bits/stdc++.h>
using namespace std;
int main() {
  int nTests;
  scanf("%d", &nTests);
  for (int test = 1; test <= nTests; ++test) {
    int ia, ib;
    double a, b;
    scanf("%d %d", &ia, &ib);
    a = ia;
    b = ib;
    double ans;
    if (ib > 0) {
      double t = min(b, a / 4);
      ans = 0.5 + ((ia > 0) ? (0.5 / b) * (t - 2 * t * t / a) : 0);
    } else {
      ans = 1;
    }
    printf("%.10lf\n", ans);
  }
  return 0;
}
