#include <bits/stdc++.h>
using namespace std;
const int INF = 0x7fffffff;
const double Pi = acos(-1);
int main() {
  int i, Case;
  int A, B;
  double Ans;
  scanf("%d", &Case);
  for (i = 1; i <= Case; i++) {
    scanf("%d%d", &A, &B);
    if (B == 0)
      Ans = 1.0;
    else {
      if (A >= 4 * B)
        Ans = 1.0 - (double)B / (double)A;
      else
        Ans = 0.5 + (double)A / (double)B / 16.0;
    }
    printf("%.8lf\n", Ans);
  }
  return 0;
}
