def binaryRepresentation(self, n):
        """
        NOTICE: As of 14 April 2015, LintCode OJ has bug in test case 12 of this question since 0.6418459415435791
        cannot be represented as binary representation because 0.6418459415435791 becomes
        0.10100100010100000000001111111111111111111111111111111111111000...


        difficult part: determine whether the fraction can be represented in binary
        if cannot represent, repeat forever, then cut-off at 32bit as in int

        One may check whether the last digit of decimal part is 5, but it does not work for 0.12345

        :param n: Given a decimal number that is passed in as a string
        :return: A string
        """
        dec_part = ""
        if n in ".":
            int_part, dec_part = n.split(".")
            getcontext().prec = len(dec_part)+1
            dec_part = "."+dec_part
            if not self.is_representable(Decimal(dec_part)):
                return "ERROR"
        else:
            int_part = n

        a = self.natural_num_to_bin(int(int_part))
        b = self.fraction_to_bin(Decimal(dec_part))

        if a == "":
            a = "0"
        if b == "":
            return a
        else:
            return a+"."+b
dataset/ETHPy150Open algorhythms/LintCode/Binary Representation.py/Solution.binaryRepresentation/swapped operands of `in`