Java tutorial
//package com.java2s; //License from project: Apache License public class Main { public static int merkleLevels(long x) { Double tmp = (Math.log(x) / Math.log(2)); if (tmp - ((int) (0 + tmp)) > 0.0) { return (int) (tmp + 1); } else { return (int) (0 + tmp); } } }