function to compute binary entropy of memory block