#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  double probability;
  cin >> t;
  int m[10001][2];
  for (int i = 0; i < t; i++) {
    cin >> m[i][0];
    cin >> m[i][1];
    if ((m[i][0] == 0) && (m[i][1] != 0)) {
      probability = 1. / 2;
      cout << probability << endl;
      continue;
    }
    if ((m[i][0] == 0) && (m[i][1] == 0)) {
      probability = 1.;
      cout << probability << endl;
      continue;
    }
    if ((m[i][0] != 0) && (m[i][1] == 0)) {
      probability = 1.;
      cout << probability << endl;
      continue;
    }
    if (m[i][0] <= 4 * m[i][1]) {
      probability = 1. / 2 + (1. / 16) * (m[i][0] / (double)m[i][1]);
      cout << probability << endl;
    } else {
      probability = 1. - (m[i][1] / (double)m[i][0]);
      cout << probability << endl;
    }
  }
  return 0;
}
