import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		sc.close();
		BigDecimal n = new BigDecimal(N);
		int binaryTarget = Integer.toBinaryString(K).length();
		String binaryLong = Integer.toBinaryString(K);
		int diff = N - K;
		BigDecimal ans = BigDecimal.ZERO;
		if (diff < 0) {
			for (int i = 1; i < N + 1; i++) {
				int a = Integer.toBinaryString(i).length();
				long a_bin = Long.parseLong(Integer.toBinaryString(i));
				long sub = Long.parseLong(binaryLong.substring(0, a));
				int b = binaryTarget - a;
				if (a_bin < sub) {
					b++;
				}
				if (a_bin == sub && binaryLong.substring(a, binaryTarget).contains("1")) {
					b++;
				}
				BigDecimal c = new BigDecimal(Math.pow(2, b)).multiply(n);
				ans = ans.add(BigDecimal.ONE.divide(c, 15, BigDecimal.ROUND_DOWN));
			}
		} else {
			for (int i = 1; i < K + 1; i++) {
				int a = Integer.toBinaryString(i).length();
				long a_bin = Long.parseLong(Integer.toBinaryString(i));
				long sub = Long.parseLong(binaryLong.substring(0, a));
				int b = binaryTarget - a;
				if (a_bin < sub) {
					b++;
				}
				if (a_bin == sub && binaryLong.substring(a, binaryTarget).contains("1")) {
					b++;
				}
				BigDecimal c = new BigDecimal(Math.pow(2, b)).multiply(n);
				ans = ans.add(BigDecimal.ONE.divide(c, 15, BigDecimal.ROUND_DOWN));
			}
			ans = ans.add(
					BigDecimal.ONE.multiply(new BigDecimal(diff)).divide(n, 15, BigDecimal.ROUND_DOWN));
		}
		System.out.println(ans);
	}
} import java.math.BigDecimal; BigDecimal java.math import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		sc.close();
		BigDecimal n = new BigDecimal(N);
		int binaryTarget = Integer.toBinaryString(K).length();
		String binaryLong = Integer.toBinaryString(K);
		int diff = N - K;
		BigDecimal ans = BigDecimal.ZERO;
		if (diff < 0) {
			for (int i = 1; i < N + 1; i++) {
				int a = Integer.toBinaryString(i).length();
				long a_bin = Long.parseLong(Integer.toBinaryString(i));
				long sub = Long.parseLong(binaryLong.substring(0, a));
				int b = binaryTarget - a;
				if (a_bin < sub) {
					b++;
				}
				if (a_bin == sub && binaryLong.substring(a, binaryTarget).contains("1")) {
					b++;
				}
				BigDecimal c = new BigDecimal(Math.pow(2, b)).multiply(n);
				ans = ans.add(BigDecimal.ONE.divide(c, 15, BigDecimal.ROUND_DOWN));
			}
		} else {
			for (int i = 1; i < K + 1; i++) {
				int a = Integer.toBinaryString(i).length();
				long a_bin = Long.parseLong(Integer.toBinaryString(i));
				long sub = Long.parseLong(binaryLong.substring(0, a));
				int b = binaryTarget - a;
				if (a_bin < sub) {
					b++;
				}
				if (a_bin == sub && binaryLong.substring(a, binaryTarget).contains("1")) {
					b++;
				}
				BigDecimal c = new BigDecimal(Math.pow(2, b)).multiply(n);
				ans = ans.add(BigDecimal.ONE.divide(c, 15, BigDecimal.ROUND_DOWN));
			}
			ans = ans.add(
					BigDecimal.ONE.multiply(new BigDecimal(diff)).divide(n, 15, BigDecimal.ROUND_DOWN));
		}
		System.out.println(ans);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		sc.close();
		BigDecimal n = new BigDecimal(N);
		int binaryTarget = Integer.toBinaryString(K).length();
		String binaryLong = Integer.toBinaryString(K);
		int diff = N - K;
		BigDecimal ans = BigDecimal.ZERO;
		if (diff < 0) {
			for (int i = 1; i < N + 1; i++) {
				int a = Integer.toBinaryString(i).length();
				long a_bin = Long.parseLong(Integer.toBinaryString(i));
				long sub = Long.parseLong(binaryLong.substring(0, a));
				int b = binaryTarget - a;
				if (a_bin < sub) {
					b++;
				}
				if (a_bin == sub && binaryLong.substring(a, binaryTarget).contains("1")) {
					b++;
				}
				BigDecimal c = new BigDecimal(Math.pow(2, b)).multiply(n);
				ans = ans.add(BigDecimal.ONE.divide(c, 15, BigDecimal.ROUND_DOWN));
			}
		} else {
			for (int i = 1; i < K + 1; i++) {
				int a = Integer.toBinaryString(i).length();
				long a_bin = Long.parseLong(Integer.toBinaryString(i));
				long sub = Long.parseLong(binaryLong.substring(0, a));
				int b = binaryTarget - a;
				if (a_bin < sub) {
					b++;
				}
				if (a_bin == sub && binaryLong.substring(a, binaryTarget).contains("1")) {
					b++;
				}
				BigDecimal c = new BigDecimal(Math.pow(2, b)).multiply(n);
				ans = ans.add(BigDecimal.ONE.divide(c, 15, BigDecimal.ROUND_DOWN));
			}
			ans = ans.add(
					BigDecimal.ONE.multiply(new BigDecimal(diff)).divide(n, 15, BigDecimal.ROUND_DOWN));
		}
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		sc.close();
		BigDecimal n = new BigDecimal(N);
		int binaryTarget = Integer.toBinaryString(K).length();
		String binaryLong = Integer.toBinaryString(K);
		int diff = N - K;
		BigDecimal ans = BigDecimal.ZERO;
		if (diff < 0) {
			for (int i = 1; i < N + 1; i++) {
				int a = Integer.toBinaryString(i).length();
				long a_bin = Long.parseLong(Integer.toBinaryString(i));
				long sub = Long.parseLong(binaryLong.substring(0, a));
				int b = binaryTarget - a;
				if (a_bin < sub) {
					b++;
				}
				if (a_bin == sub && binaryLong.substring(a, binaryTarget).contains("1")) {
					b++;
				}
				BigDecimal c = new BigDecimal(Math.pow(2, b)).multiply(n);
				ans = ans.add(BigDecimal.ONE.divide(c, 15, BigDecimal.ROUND_DOWN));
			}
		} else {
			for (int i = 1; i < K + 1; i++) {
				int a = Integer.toBinaryString(i).length();
				long a_bin = Long.parseLong(Integer.toBinaryString(i));
				long sub = Long.parseLong(binaryLong.substring(0, a));
				int b = binaryTarget - a;
				if (a_bin < sub) {
					b++;
				}
				if (a_bin == sub && binaryLong.substring(a, binaryTarget).contains("1")) {
					b++;
				}
				BigDecimal c = new BigDecimal(Math.pow(2, b)).multiply(n);
				ans = ans.add(BigDecimal.ONE.divide(c, 15, BigDecimal.ROUND_DOWN));
			}
			ans = ans.add(
					BigDecimal.ONE.multiply(new BigDecimal(diff)).divide(n, 15, BigDecimal.ROUND_DOWN));
		}
		System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc sc.close() sc.close sc BigDecimal n = new BigDecimal(N); n new BigDecimal(N) int binaryTarget = Integer.toBinaryString(K).length(); binaryTarget Integer.toBinaryString(K).length() Integer.toBinaryString(K).length Integer.toBinaryString(K) Integer.toBinaryString Integer K String binaryLong = Integer.toBinaryString(K); binaryLong Integer.toBinaryString(K) Integer.toBinaryString Integer K int diff = N - K; diff N - K N K BigDecimal ans = BigDecimal.ZERO; ans BigDecimal.ZERO BigDecimal BigDecimal.ZERO if (diff < 0) {
			for (int i = 1; i < N + 1; i++) {
				int a = Integer.toBinaryString(i).length();
				long a_bin = Long.parseLong(Integer.toBinaryString(i));
				long sub = Long.parseLong(binaryLong.substring(0, a));
				int b = binaryTarget - a;
				if (a_bin < sub) {
					b++;
				}
				if (a_bin == sub && binaryLong.substring(a, binaryTarget).contains("1")) {
					b++;
				}
				BigDecimal c = new BigDecimal(Math.pow(2, b)).multiply(n);
				ans = ans.add(BigDecimal.ONE.divide(c, 15, BigDecimal.ROUND_DOWN));
			}
		} else {
			for (int i = 1; i < K + 1; i++) {
				int a = Integer.toBinaryString(i).length();
				long a_bin = Long.parseLong(Integer.toBinaryString(i));
				long sub = Long.parseLong(binaryLong.substring(0, a));
				int b = binaryTarget - a;
				if (a_bin < sub) {
					b++;
				}
				if (a_bin == sub && binaryLong.substring(a, binaryTarget).contains("1")) {
					b++;
				}
				BigDecimal c = new BigDecimal(Math.pow(2, b)).multiply(n);
				ans = ans.add(BigDecimal.ONE.divide(c, 15, BigDecimal.ROUND_DOWN));
			}
			ans = ans.add(
					BigDecimal.ONE.multiply(new BigDecimal(diff)).divide(n, 15, BigDecimal.ROUND_DOWN));
		} diff < 0 diff 0 {
			for (int i = 1; i < N + 1; i++) {
				int a = Integer.toBinaryString(i).length();
				long a_bin = Long.parseLong(Integer.toBinaryString(i));
				long sub = Long.parseLong(binaryLong.substring(0, a));
				int b = binaryTarget - a;
				if (a_bin < sub) {
					b++;
				}
				if (a_bin == sub && binaryLong.substring(a, binaryTarget).contains("1")) {
					b++;
				}
				BigDecimal c = new BigDecimal(Math.pow(2, b)).multiply(n);
				ans = ans.add(BigDecimal.ONE.divide(c, 15, BigDecimal.ROUND_DOWN));
			}
		} for (int i = 1; i < N + 1; i++) {
				int a = Integer.toBinaryString(i).length();
				long a_bin = Long.parseLong(Integer.toBinaryString(i));
				long sub = Long.parseLong(binaryLong.substring(0, a));
				int b = binaryTarget - a;
				if (a_bin < sub) {
					b++;
				}
				if (a_bin == sub && binaryLong.substring(a, binaryTarget).contains("1")) {
					b++;
				}
				BigDecimal c = new BigDecimal(Math.pow(2, b)).multiply(n);
				ans = ans.add(BigDecimal.ONE.divide(c, 15, BigDecimal.ROUND_DOWN));
			} int i = 1; int i = 1; i 1 i < N + 1 i N + 1 N 1 i++ i++ i {
				int a = Integer.toBinaryString(i).length();
				long a_bin = Long.parseLong(Integer.toBinaryString(i));
				long sub = Long.parseLong(binaryLong.substring(0, a));
				int b = binaryTarget - a;
				if (a_bin < sub) {
					b++;
				}
				if (a_bin == sub && binaryLong.substring(a, binaryTarget).contains("1")) {
					b++;
				}
				BigDecimal c = new BigDecimal(Math.pow(2, b)).multiply(n);
				ans = ans.add(BigDecimal.ONE.divide(c, 15, BigDecimal.ROUND_DOWN));
			} {
				int a = Integer.toBinaryString(i).length();
				long a_bin = Long.parseLong(Integer.toBinaryString(i));
				long sub = Long.parseLong(binaryLong.substring(0, a));
				int b = binaryTarget - a;
				if (a_bin < sub) {
					b++;
				}
				if (a_bin == sub && binaryLong.substring(a, binaryTarget).contains("1")) {
					b++;
				}
				BigDecimal c = new BigDecimal(Math.pow(2, b)).multiply(n);
				ans = ans.add(BigDecimal.ONE.divide(c, 15, BigDecimal.ROUND_DOWN));
			} int a = Integer.toBinaryString(i).length(); a Integer.toBinaryString(i).length() Integer.toBinaryString(i).length Integer.toBinaryString(i) Integer.toBinaryString Integer i long a_bin = Long.parseLong(Integer.toBinaryString(i)); a_bin Long.parseLong(Integer.toBinaryString(i)) Long.parseLong Long Integer.toBinaryString(i) Integer.toBinaryString Integer i long sub = Long.parseLong(binaryLong.substring(0, a)); sub Long.parseLong(binaryLong.substring(0, a)) Long.parseLong Long binaryLong.substring(0, a) binaryLong.substring binaryLong 0 a int b = binaryTarget - a; b binaryTarget - a binaryTarget a if (a_bin < sub) {
					b++;
				} a_bin < sub a_bin sub {
					b++;
				} b++ b if (a_bin == sub && binaryLong.substring(a, binaryTarget).contains("1")) {
					b++;
				} a_bin == sub && binaryLong.substring(a, binaryTarget).contains("1") a_bin == sub a_bin sub binaryLong.substring(a, binaryTarget).contains("1") binaryLong.substring(a, binaryTarget).contains binaryLong.substring(a, binaryTarget) binaryLong.substring binaryLong a binaryTarget "1" {
					b++;
				} b++ b BigDecimal c = new BigDecimal(Math.pow(2, b)).multiply(n); c new BigDecimal(Math.pow(2, b)).multiply(n) new BigDecimal(Math.pow(2, b)).multiply new BigDecimal(Math.pow(2, b)) n ans = ans.add(BigDecimal.ONE.divide(c, 15, BigDecimal.ROUND_DOWN)) ans ans.add(BigDecimal.ONE.divide(c, 15, BigDecimal.ROUND_DOWN)) ans.add ans BigDecimal.ONE.divide(c, 15, BigDecimal.ROUND_DOWN) BigDecimal.ONE.divide BigDecimal.ONE BigDecimal BigDecimal.ONE c 15 BigDecimal.ROUND_DOWN BigDecimal BigDecimal.ROUND_DOWN {
			for (int i = 1; i < K + 1; i++) {
				int a = Integer.toBinaryString(i).length();
				long a_bin = Long.parseLong(Integer.toBinaryString(i));
				long sub = Long.parseLong(binaryLong.substring(0, a));
				int b = binaryTarget - a;
				if (a_bin < sub) {
					b++;
				}
				if (a_bin == sub && binaryLong.substring(a, binaryTarget).contains("1")) {
					b++;
				}
				BigDecimal c = new BigDecimal(Math.pow(2, b)).multiply(n);
				ans = ans.add(BigDecimal.ONE.divide(c, 15, BigDecimal.ROUND_DOWN));
			}
			ans = ans.add(
					BigDecimal.ONE.multiply(new BigDecimal(diff)).divide(n, 15, BigDecimal.ROUND_DOWN));
		} for (int i = 1; i < K + 1; i++) {
				int a = Integer.toBinaryString(i).length();
				long a_bin = Long.parseLong(Integer.toBinaryString(i));
				long sub = Long.parseLong(binaryLong.substring(0, a));
				int b = binaryTarget - a;
				if (a_bin < sub) {
					b++;
				}
				if (a_bin == sub && binaryLong.substring(a, binaryTarget).contains("1")) {
					b++;
				}
				BigDecimal c = new BigDecimal(Math.pow(2, b)).multiply(n);
				ans = ans.add(BigDecimal.ONE.divide(c, 15, BigDecimal.ROUND_DOWN));
			} int i = 1; int i = 1; i 1 i < K + 1 i K + 1 K 1 i++ i++ i {
				int a = Integer.toBinaryString(i).length();
				long a_bin = Long.parseLong(Integer.toBinaryString(i));
				long sub = Long.parseLong(binaryLong.substring(0, a));
				int b = binaryTarget - a;
				if (a_bin < sub) {
					b++;
				}
				if (a_bin == sub && binaryLong.substring(a, binaryTarget).contains("1")) {
					b++;
				}
				BigDecimal c = new BigDecimal(Math.pow(2, b)).multiply(n);
				ans = ans.add(BigDecimal.ONE.divide(c, 15, BigDecimal.ROUND_DOWN));
			} {
				int a = Integer.toBinaryString(i).length();
				long a_bin = Long.parseLong(Integer.toBinaryString(i));
				long sub = Long.parseLong(binaryLong.substring(0, a));
				int b = binaryTarget - a;
				if (a_bin < sub) {
					b++;
				}
				if (a_bin == sub && binaryLong.substring(a, binaryTarget).contains("1")) {
					b++;
				}
				BigDecimal c = new BigDecimal(Math.pow(2, b)).multiply(n);
				ans = ans.add(BigDecimal.ONE.divide(c, 15, BigDecimal.ROUND_DOWN));
			} int a = Integer.toBinaryString(i).length(); a Integer.toBinaryString(i).length() Integer.toBinaryString(i).length Integer.toBinaryString(i) Integer.toBinaryString Integer i long a_bin = Long.parseLong(Integer.toBinaryString(i)); a_bin Long.parseLong(Integer.toBinaryString(i)) Long.parseLong Long Integer.toBinaryString(i) Integer.toBinaryString Integer i long sub = Long.parseLong(binaryLong.substring(0, a)); sub Long.parseLong(binaryLong.substring(0, a)) Long.parseLong Long binaryLong.substring(0, a) binaryLong.substring binaryLong 0 a int b = binaryTarget - a; b binaryTarget - a binaryTarget a if (a_bin < sub) {
					b++;
				} a_bin < sub a_bin sub {
					b++;
				} b++ b if (a_bin == sub && binaryLong.substring(a, binaryTarget).contains("1")) {
					b++;
				} a_bin == sub && binaryLong.substring(a, binaryTarget).contains("1") a_bin == sub a_bin sub binaryLong.substring(a, binaryTarget).contains("1") binaryLong.substring(a, binaryTarget).contains binaryLong.substring(a, binaryTarget) binaryLong.substring binaryLong a binaryTarget "1" {
					b++;
				} b++ b BigDecimal c = new BigDecimal(Math.pow(2, b)).multiply(n); c new BigDecimal(Math.pow(2, b)).multiply(n) new BigDecimal(Math.pow(2, b)).multiply new BigDecimal(Math.pow(2, b)) n ans = ans.add(BigDecimal.ONE.divide(c, 15, BigDecimal.ROUND_DOWN)) ans ans.add(BigDecimal.ONE.divide(c, 15, BigDecimal.ROUND_DOWN)) ans.add ans BigDecimal.ONE.divide(c, 15, BigDecimal.ROUND_DOWN) BigDecimal.ONE.divide BigDecimal.ONE BigDecimal BigDecimal.ONE c 15 BigDecimal.ROUND_DOWN BigDecimal BigDecimal.ROUND_DOWN ans = ans.add(
					BigDecimal.ONE.multiply(new BigDecimal(diff)).divide(n, 15, BigDecimal.ROUND_DOWN)) ans ans.add(
					BigDecimal.ONE.multiply(new BigDecimal(diff)).divide(n, 15, BigDecimal.ROUND_DOWN)) ans.add ans BigDecimal.ONE.multiply(new BigDecimal(diff)).divide(n, 15, BigDecimal.ROUND_DOWN) BigDecimal.ONE.multiply(new BigDecimal(diff)).divide BigDecimal.ONE.multiply(new BigDecimal(diff)) BigDecimal.ONE.multiply BigDecimal.ONE BigDecimal BigDecimal.ONE new BigDecimal(diff) n 15 BigDecimal.ROUND_DOWN BigDecimal BigDecimal.ROUND_DOWN System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		sc.close();
		BigDecimal n = new BigDecimal(N);
		int binaryTarget = Integer.toBinaryString(K).length();
		String binaryLong = Integer.toBinaryString(K);
		int diff = N - K;
		BigDecimal ans = BigDecimal.ZERO;
		if (diff < 0) {
			for (int i = 1; i < N + 1; i++) {
				int a = Integer.toBinaryString(i).length();
				long a_bin = Long.parseLong(Integer.toBinaryString(i));
				long sub = Long.parseLong(binaryLong.substring(0, a));
				int b = binaryTarget - a;
				if (a_bin < sub) {
					b++;
				}
				if (a_bin == sub && binaryLong.substring(a, binaryTarget).contains("1")) {
					b++;
				}
				BigDecimal c = new BigDecimal(Math.pow(2, b)).multiply(n);
				ans = ans.add(BigDecimal.ONE.divide(c, 15, BigDecimal.ROUND_DOWN));
			}
		} else {
			for (int i = 1; i < K + 1; i++) {
				int a = Integer.toBinaryString(i).length();
				long a_bin = Long.parseLong(Integer.toBinaryString(i));
				long sub = Long.parseLong(binaryLong.substring(0, a));
				int b = binaryTarget - a;
				if (a_bin < sub) {
					b++;
				}
				if (a_bin == sub && binaryLong.substring(a, binaryTarget).contains("1")) {
					b++;
				}
				BigDecimal c = new BigDecimal(Math.pow(2, b)).multiply(n);
				ans = ans.add(BigDecimal.ONE.divide(c, 15, BigDecimal.ROUND_DOWN));
			}
			ans = ans.add(
					BigDecimal.ONE.multiply(new BigDecimal(diff)).divide(n, 15, BigDecimal.ROUND_DOWN));
		}
		System.out.println(ans);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		sc.close();
		BigDecimal n = new BigDecimal(N);
		int binaryTarget = Integer.toBinaryString(K).length();
		String binaryLong = Integer.toBinaryString(K);
		int diff = N - K;
		BigDecimal ans = BigDecimal.ZERO;
		if (diff < 0) {
			for (int i = 1; i < N + 1; i++) {
				int a = Integer.toBinaryString(i).length();
				long a_bin = Long.parseLong(Integer.toBinaryString(i));
				long sub = Long.parseLong(binaryLong.substring(0, a));
				int b = binaryTarget - a;
				if (a_bin < sub) {
					b++;
				}
				if (a_bin == sub && binaryLong.substring(a, binaryTarget).contains("1")) {
					b++;
				}
				BigDecimal c = new BigDecimal(Math.pow(2, b)).multiply(n);
				ans = ans.add(BigDecimal.ONE.divide(c, 15, BigDecimal.ROUND_DOWN));
			}
		} else {
			for (int i = 1; i < K + 1; i++) {
				int a = Integer.toBinaryString(i).length();
				long a_bin = Long.parseLong(Integer.toBinaryString(i));
				long sub = Long.parseLong(binaryLong.substring(0, a));
				int b = binaryTarget - a;
				if (a_bin < sub) {
					b++;
				}
				if (a_bin == sub && binaryLong.substring(a, binaryTarget).contains("1")) {
					b++;
				}
				BigDecimal c = new BigDecimal(Math.pow(2, b)).multiply(n);
				ans = ans.add(BigDecimal.ONE.divide(c, 15, BigDecimal.ROUND_DOWN));
			}
			ans = ans.add(
					BigDecimal.ONE.multiply(new BigDecimal(diff)).divide(n, 15, BigDecimal.ROUND_DOWN));
		}
		System.out.println(ans);
	}
} Main
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		sc.close();
		BigDecimal n = new BigDecimal(N);
		int binaryTarget = Integer.toBinaryString(K).length();
		String binaryLong = Integer.toBinaryString(K);
		int diff = N - K;
		BigDecimal ans = BigDecimal.ZERO;
		if (diff < 0) {
			for (int i = 1; i < N + 1; i++) {
				int a = Integer.toBinaryString(i).length();
				long a_bin = Long.parseLong(Integer.toBinaryString(i));
				long sub = Long.parseLong(binaryLong.substring(0, a));
				int b = binaryTarget - a;
				if (a_bin < sub) {
					b++;
				}
				if (a_bin == sub && binaryLong.substring(a, binaryTarget).contains("1")) {
					b++;
				}
				BigDecimal c = new BigDecimal(Math.pow(2, b)).multiply(n);
				ans = ans.add(BigDecimal.ONE.divide(c, 15, BigDecimal.ROUND_DOWN));
			}
		} else {
			for (int i = 1; i < K + 1; i++) {
				int a = Integer.toBinaryString(i).length();
				long a_bin = Long.parseLong(Integer.toBinaryString(i));
				long sub = Long.parseLong(binaryLong.substring(0, a));
				int b = binaryTarget - a;
				if (a_bin < sub) {
					b++;
				}
				if (a_bin == sub && binaryLong.substring(a, binaryTarget).contains("1")) {
					b++;
				}
				BigDecimal c = new BigDecimal(Math.pow(2, b)).multiply(n);
				ans = ans.add(BigDecimal.ONE.divide(c, 15, BigDecimal.ROUND_DOWN));
			}
			ans = ans.add(
					BigDecimal.ONE.multiply(new BigDecimal(diff)).divide(n, 15, BigDecimal.ROUND_DOWN));
		}
		System.out.println(ans);
	}
}
