本文整理汇总了Python中typhon.objects.data.IntObject类的典型用法代码示例。如果您正苦于以下问题:Python IntObject类的具体用法?Python IntObject怎么用?Python IntObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IntObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testMulDouble
def testMulDouble(self):
"""
Ints are promoted by doubles during multiplication.
"""
i = IntObject(4)
result = i.call(u"multiply", [DoubleObject(2.1)])
self.assertTrue(isinstance(result, DoubleObject))
self.assertEqual(result.getDouble(), 8.4)
示例2: testPow
def testPow(self):
i = IntObject(3)
result = i.call(u"pow", [IntObject(100)])
self.assertTrue(result.bi.eq(rbigint.fromint(3).pow(rbigint.fromint(100))))
示例3: testPowSmall
def testPowSmall(self):
i = IntObject(5)
result = i.call(u"pow", [IntObject(7)])
self.assertEqual(result.getInt(), 78125)
示例4: testOr
def testOr(self):
i = IntObject(0x3)
result = i.call(u"or", [IntObject(0x5)])
self.assertEqual(result.getInt(), 0x7)
示例5: testApproxDivideNaN
def testApproxDivideNaN(self):
i = IntObject(0)
result = i.call(u"approxDivide", [i])
self.assertTrue(math.isnan(result.getDouble()))
示例6: testSubtractDouble
def testSubtractDouble(self):
i = IntObject(5)
result = i.call(u"subtract", [DoubleObject(1.5)])
self.assertAlmostEqual(result.getDouble(), 3.5)
示例7: testShiftRightLarge
def testShiftRightLarge(self):
i = IntObject(0x7fffffffffffffff)
result = i.call(u"shiftRight", [IntObject(64)])
self.assertEqual(result.getInt(), 0x0)
示例8: testShiftLeftFar
def testShiftLeftFar(self):
i = IntObject(0x1)
result = i.call(u"shiftLeft", [IntObject(65)])
bi = rbigint.fromint(0x1).lshift(65)
self.assertTrue(result.bi.eq(bi))
示例9: testMax
def testMax(self):
i = IntObject(3)
result = i.call(u"max", [IntObject(5)])
self.assertEqual(result.getInt(), 5)
示例10: testComplement
def testComplement(self):
i = IntObject(5)
result = i.call(u"complement", [])
self.assertEqual(result.getInt(), -6)
示例11: testApproxDivideBigInt
def testApproxDivideBigInt(self):
i = IntObject(7937000378463977)
# Hack.
bi = BigInt(rbigint.fromint(1000000000000000000).int_mul(10))
result = i.call(u"approxDivide", [bi])
self.assertAlmostEqual(result._d, 0.0007937000378463977)
示例12: testApproxDivide
def testApproxDivide(self):
i = IntObject(4)
result = i.call(u"approxDivide", [IntObject(2)])
self.assertAlmostEqual(result.getDouble(), 2.0)
示例13: testAddDouble
def testAddDouble(self):
i = IntObject(32)
result = i.call(u"add", [DoubleObject(1.1)])
self.assertAlmostEqual(result.getDouble(), 33.1)
示例14: testAdd
def testAdd(self):
i = IntObject(32)
result = i.call(u"add", [IntObject(11)])
self.assertEqual(result.getInt(), 43)
示例15: testModPow
def testModPow(self):
i = IntObject(3)
result = i.call(u"modPow", [IntObject(1000000), IntObject(255)])
self.assertEqual(result.getInt(), 171)