#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  scanf("%d", &t);
  ;
  while (t--) {
    int a, b;
    scanf("%d %d", &a, &b);
    ;
    cout << setprecision(9) << fixed;
    if (!b)
      cout << 1 << endl;
    else if (!a)
      cout << 0.5 << endl;
    else {
      double tmp = min(a, 4 * b);
      cout << ((tmp * tmp) / (16 * b) + tmp / 2.0 + max(0, a - 4 * b)) / a
           << endl;
    }
  }
  return 0;
}
