; The purpose of this function is to convert any binary number (expressed as a string of zeros and ones) into its decimal equivalent. function binary2decimal, binary_number ;binary should be a string containing zeros and ones Byte_binary = Byte(binary_number) Not_binary = where (byte_binary lt 48 or byte_binary gt 49) If not_binary [0] ne -1 then Message, 'Input is not a string!' dim = N_Elements(byte_binary) decimal = Total( (Byte(Reverse(binary_Number)) EQ 49) * 2L^Indgen(dim) ) return, decimal end