#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b, long long modi) {
  long long res = 1;
  while (b) {
    if (b % 2) res = (res * a) % modi;
    b /= 2;
    a = (a * a) % modi;
  }
  return res;
}
int dirx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int diry[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
long long n, k, sum = 0, ans = 0, cur = 0;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    if (b == 0) {
      cout << "1\n";
      continue;
    }
    if (a == 0) {
      cout << "0.5\n";
      continue;
    }
    double ans;
    if (a <= 4 * b)
      ans = (a * b + ((a * a) / (double(8)))) / (double(2 * a * b));
    else
      ans = (2 * a * b - 2 * b * b) / (double(2 * a * b));
    cout << fixed << setprecision(9) << ans << "\n";
  }
  return 0;
}
