def testEncryptDecryptFloatAddFiniteNumbers(self):
    logging.debug('Running testEncryptDecryptFloatAddFiniteNumbers method.')
    # add a chain of small positive numbers
    c_1_0 = _PAILLIER1.EncryptFloat(1.0)
    c_2_0 = _PAILLIER1.EncryptFloat(2.0)
    c_3_0 = _PAILLIER1.Add(c_2_0, c_1_0)
    c_5_0 = _PAILLIER1.Add(c_3_0, c_2_0)
    self.assertEquals(3.0, _PAILLIER1.DecryptFloat(c_3_0))
    self.assertEquals(5.0, _PAILLIER1.DecryptFloat(c_5_0))
    # add a chain of small negative numbers
    c_2_0neg = _PAILLIER1.EncryptFloat(-2.0)
    c_4_0neg = _PAILLIER1.EncryptFloat(-4.0)
    c_6_0neg = _PAILLIER1.Add(c_2_0neg, c_4_0neg)
    self.assertEquals(-6.0, _PAILLIER1.DecryptFloat(c_6_0neg))
    # add positive and negative small numbers
    c_1_0neg = _PAILLIER1.Add(c_5_0, c_6_0neg)
    self.assertEquals(-1.0, _PAILLIER1.DecryptFloat(c_1_0neg))
    # add a large positive and negative number
    large1 = 1.999999999999999 * 2**389
    c_large1 = _PAILLIER1.EncryptFloat(large1)
    c_large2neg = _PAILLIER1.EncryptFloat(-0.999999999999999 * 2**389)
    decrypted = _PAILLIER1.DecryptFloat(_PAILLIER1.Add(c_large1, c_large2neg))
    # check close to 1.0 * 2**389
    self.assertTrue(decrypted > .9999999999999998 * 2**389)
    self.assertTrue(decrypted < 1.000000000000002 * 2**389)
    # add a very large and a relatively small number --> same large number.
    c_small1 = _PAILLIER1.EncryptFloat(.99999999999999 * 2**-430)
    decrypted = _PAILLIER1.DecryptFloat(_PAILLIER1.Add(c_large1, c_small1))
    self.assertEquals(large1, decrypted)
    # add two subnormal numbers.
    smallest_subnormal = 2**-441
    c_smallest_subnormal = _PAILLIER1.EncryptFloat(smallest_subnormal)
    c_2smallest_subnormal = _PAILLIER1.Add(c_smallest_subnormal,
                                           c_smallest_subnormal)
    self.assertEquals(2**-440, _PAILLIER1.DecryptFloat(c_2smallest_subnormal))
    # add a positive and negative subnormal numbers
    c_smallest_subnormal_neg = _PAILLIER1.EncryptFloat(-2**-441)
    self.assertEquals(smallest_subnormal, _PAILLIER1.DecryptFloat(
        _PAILLIER1.Add(c_2smallest_subnormal, c_smallest_subnormal_neg)))
dataset/ETHPy150Open google/encrypted-bigquery-client/src/paillier_test.py/PaillierTest.testEncryptDecryptFloatAddFiniteNumbers/original