示例#1
0
 def testBitLength(self):
     bi = BigInt(rbigint.fromint(42))
     result = bi.call(u"bitLength", [])
     self.assertEqual(result.getInt(), 6)
示例#2
0
 def testApproxDivide(self):
     bi = BigInt(rbigint.fromint(7937000378463977))
     # Hack.
     bj = BigInt(rbigint.fromint(1000000000000000000).int_mul(10))
     result = bi.call(u"approxDivide", [bj])
     self.assertAlmostEqual(result._d, 0.0007937000378463977)
示例#3
0
文件: test_data.py 项目: dckc/typhon
 def testXorInt(self):
     bi = BigInt(rbigint.fromint(0xcccc))
     result = bi.call(u"xor", [IntObject(0xaaaa)])
     self.assertEqual(result.getInt(), 0x6666)
示例#4
0
 def testBitLength(self):
     bi = BigInt(rbigint.fromint(42))
     result = bi.call(u"bitLength", [])
     self.assertEqual(result.getInt(), 6)
示例#5
0
 def testComplement(self):
     bi = BigInt(rbigint.fromint(6))
     result = bi.call(u"complement", [])
     self.assertTrue(result.bi.int_eq(-7))
示例#6
0
 def testOpCmpInt(self):
     bi = BigInt(rbigint.fromint(6))
     i = IntObject(2)
     result = bi.call(u"op__cmp", [i])
     self.assertEqual(result.getInt(), 1)
示例#7
0
 def testShiftRight(self):
     bi = BigInt(rbigint.fromint(42))
     result = bi.call(u"shiftRight", [IntObject(2)])
     self.assertTrue(result.bi.int_eq(10))
示例#8
0
 def testXorInt(self):
     bi = BigInt(rbigint.fromint(0xcccc))
     result = bi.call(u"xor", [IntObject(0xaaaa)])
     self.assertEqual(result.getInt(), 0x6666)
示例#9
0
 def testAndInt(self):
     bi = BigInt(rbigint.fromint(0x3fffffffffffffff).int_mul(3))
     result = bi.call(u"and", [IntObject(0xffff)])
     self.assertEqual(result.getInt(), 0xfffd)
示例#10
0
文件: test_data.py 项目: dckc/typhon
 def testFloorDivideDouble(self):
     bi = BigInt(rbigint.fromint(2).pow(rbigint.fromint(65)))
     result = bi.call(u"floorDivide", [DoubleObject(2.0)])
     self.assertTrue(result.bi.eq(rbigint.fromint(2).pow(rbigint.fromint(64))))
示例#11
0
 def testShiftRight(self):
     bi = BigInt(rbigint.fromint(42))
     result = bi.call(u"shiftRight", [IntObject(2)])
     self.assertEqual(result.getInt(), 10)
示例#12
0
文件: test_data.py 项目: dckc/typhon
 def testApproxDivideDouble(self):
     bi = BigInt(rbigint.fromint(1))
     result = bi.call(u"approxDivide", [DoubleObject(32.0)])
     self.assertAlmostEqual(result._d, 1.0 / 32.0)
示例#13
0
文件: test_data.py 项目: dckc/typhon
 def testComplement(self):
     bi = BigInt(rbigint.fromint(6))
     result = bi.call(u"complement", [])
     self.assertEqual(result.getInt(), -7)
示例#14
0
文件: test_data.py 项目: dckc/typhon
 def testAndInt(self):
     bi = BigInt(rbigint.fromint(0x3fffffffffffffff).int_mul(3))
     result = bi.call(u"and", [IntObject(0xffff)])
     self.assertEqual(result.getInt(), 0xfffd)
示例#15
0
 def testAndInt(self):
     bi = BigInt(rbigint.fromint(0x3fffffffffffffff).int_mul(3))
     result = bi.call(u"and", [IntObject(0xffff)])
     self.assertTrue(result.bi.int_eq(0xfffd))
示例#16
0
 def testComplement(self):
     bi = BigInt(rbigint.fromint(6))
     result = bi.call(u"complement", [])
     self.assertEqual(result.getInt(), -7)
示例#17
0
 def testComplement(self):
     bi = BigInt(rbigint.fromint(6))
     result = bi.call(u"complement", [])
     self.assertTrue(result.bi.int_eq(-7))
示例#18
0
 def testApproxDivideDouble(self):
     bi = BigInt(rbigint.fromint(1))
     result = bi.call(u"approxDivide", [DoubleObject(32.0)])
     self.assertAlmostEqual(result._d, 1.0 / 32.0)
示例#19
0
 def testApproxDivide(self):
     bi = BigInt(rbigint.fromint(7937000378463977))
     # Hack.
     bj = BigInt(rbigint.fromint(1000000000000000000).int_mul(10))
     result = bi.call(u"approxDivide", [bj])
     self.assertAlmostEqual(result._d, 0.0007937000378463977)
示例#20
0
 def testFloorDivideDouble(self):
     bi = BigInt(rbigint.fromint(2).pow(rbigint.fromint(65)))
     result = bi.call(u"floorDivide", [DoubleObject(2.0)])
     self.assertTrue(
         result.bi.eq(rbigint.fromint(2).pow(rbigint.fromint(64))))
示例#21
0
 def testXorInt(self):
     bi = BigInt(rbigint.fromint(0xcccc))
     result = bi.call(u"xor", [IntObject(0xaaaa)])
     self.assertTrue(result.bi.int_eq(0x6666))
示例#22
0
 def testApproxDivideNaN(self):
     i = BigInt(rbigint.fromint(0))
     result = i.call(u"approxDivide", [i])
     self.assertTrue(math.isnan(result.getDouble()))
示例#23
0
 def testAndInt(self):
     bi = BigInt(rbigint.fromint(0x3fffffffffffffff).int_mul(3))
     result = bi.call(u"and", [IntObject(0xffff)])
     self.assertTrue(result.bi.int_eq(0xfffd))
示例#24
0
 def testShiftRight(self):
     bi = BigInt(rbigint.fromint(42))
     result = bi.call(u"shiftRight", [IntObject(2)])
     self.assertTrue(result.bi.int_eq(10))
示例#25
0
 def testOpCmpInt(self):
     bi = BigInt(rbigint.fromint(6))
     i = IntObject(2)
     result = bi.call(u"op__cmp", [i])
     self.assertEqual(result.getInt(), 1)
示例#26
0
 def testXorInt(self):
     bi = BigInt(rbigint.fromint(0xcccc))
     result = bi.call(u"xor", [IntObject(0xaaaa)])
     self.assertTrue(result.bi.int_eq(0x6666))
示例#27
0
 def testApproxDivideNaN(self):
     i = BigInt(rbigint.fromint(0))
     result = i.call(u"approxDivide", [i])
     self.assertTrue(math.isnan(result.getDouble()))
示例#28
0
文件: test_data.py 项目: dckc/typhon
 def testShiftRight(self):
     bi = BigInt(rbigint.fromint(42))
     result = bi.call(u"shiftRight", [IntObject(2)])
     self.assertEqual(result.getInt(), 10)