Exemplo n.º 1
0
 def test_11_p(self):
     """TestRepCodeTo68Python.test_11_p(): to68() -1e40 is min Python."""
     #        print()
     #        print('-1e40 = 0x{:08X} {:s}'.format(pRepCode.to68(-1e40), self.splitBits68(pRepCode.to68(-1e40))))
     #        print('  Min = 0x{:08X} {:g}'.format(pRepCode.to68(RepCode.minValue(68)), RepCode.minValue(68)))
     self.assertEqual(pRepCode.to68(-1e40),
                      pRepCode.to68(RepCode.minValue(68)))
Exemplo n.º 2
0
 def test_time_01(self):
     """TestRepCodeTo68Time.test_time_01(): tests conversion of 1e6 of same word - Python code."""
     i = 0
     num = 1e6
     tS = time.clock()
     while i < num:
         pRepCode.to68(153.0)
         i += 1
     self.writeTimeToStdErr(tS, 68, num)
Exemplo n.º 3
0
 def test_time_11(self):
     """TestRepCodeTo68Time.test_time_11(): tests conversion of 1e5 random words - Python code."""
     i = 0
     num = 1e5
     tS = time.clock()
     myMin, myMax = RepCode.minMaxValue(68)
     while i < num:
         val = myMin + random.random() * (myMax - myMin)
         pRepCode.to68(val)
         i += 1
     self.writeTimeToStdErr(tS, 68, num)
Exemplo n.º 4
0
 def test_10_p(self):
     """TestRepCodeTo68Python.test_10_p(): to68() <3.50325e-46 is zero Python."""
     v = 3.50325e-46
     #        print()
     #        print('1e-40 = 0x{:08X} {:s} {:g}'.format(
     #            pRepCode.to68(v),
     #            self.splitBits68(pRepCode.to68(v)),
     #            pRepCode.from68(pRepCode.to68(v))),
     #        )
     self.assertEqual(0x00000001, pRepCode.to68(v))
     # Now reduce v slightly and we should see zero
     self.assertEqual(pRepCode.to68(0.99 * v), pRepCode.to68(0.0))
Exemplo n.º 5
0
 def test_04(self):
     """TestRepCodeTo68LowExponent.test_04(): Special exponent tests, full range."""
     for e in range(-150, 128, 1):
         rcWord = pRepCode.to68(math.ldexp(0.5, e))
         self.assertEqual((0.5, e), math.frexp(pRepCode.from68(rcWord)))
     for e in range(-150, 128, 1):
         rcWord = cRepCode.to68(math.ldexp(0.5, e))
         self.assertEqual((0.5, e), math.frexp(cRepCode.from68(rcWord)))
     for e in range(-150, 128, 1):
         rcWord = RepCode.to68(math.ldexp(0.5, e))
         self.assertEqual((0.5, e), math.frexp(RepCode.from68(rcWord)))
Exemplo n.º 6
0
 def test_time_02(self):
     """TestRepCodeTo68Time.test_time_02(): 1e6 same word  Cython time c.f. Python:"""
     i = 0
     num = 1e6
     tS = time.clock()
     while i < num:
         cRepCode.to68(153.0)
         i += 1
     tE_C = time.clock() - tS
     sys.stderr.write(' Cython: %.3f rate %8.0f words/S' %
                      (tE_C, num / tE_C))
     i = 0
     tS = time.clock()
     while i < num:
         pRepCode.to68(153.0)
         i += 1
     tE_P = time.clock() - tS
     sys.stderr.write(' Python: %.3f rate %8.f words/S' %
                      (tE_P, num / tE_P))
     sys.stderr.write(' %.1f%% (x%.1f) ' % ((100.0 *
                                             (tE_C / tE_P)), tE_P / tE_C))
Exemplo n.º 7
0
    def test_03(self):
        """TestRepCodeTo68LowExponent.test_03(): Special exponent tests."""
        #        print()
        for e in (-151, -150, -129, -128, 0):
            rcWord = pRepCode.to68(math.ldexp(0.5, e))
#            print(
#                  'pRepCode.to68(math.ldexp(0.5, {:4d}))'.format(e),
#                  '0x{:08x}->{:s}'.format(rcWord, math.frexp(pRepCode.from68(rcWord)))
#            )
#print()
        for e in (-151, -150, -129, -128, 0):
            rcWord = cRepCode.to68(math.ldexp(0.5, e))
Exemplo n.º 8
0
 def test_05(self):
     """TestRepCodeTo68LowExponent.test_02(): to68() exponent <-150 made to zero."""
     self.assertEqual(0x40000000, pRepCode.to68(math.ldexp(0.5, -151)))
     self.assertEqual(0x40000000, cRepCode.to68(math.ldexp(0.5, -151)))
     self.assertEqual(0x40000000, RepCode.to68(math.ldexp(0.5, -151)))
Exemplo n.º 9
0
 def test_10(self):
     """TestRepCodeTo68PyCy.test_10(): to68() -999.25 -> 0xBA831800"""
     self.assertEqual('{:b}'.format(pRepCode.to68(-999.25)),
                      '{:b}'.format(cRepCode.to68(-999.25)))
     self.assertEqual(pRepCode.to68(-999.25), cRepCode.to68(-999.25))
     self.assertEqual(RepCode.to68(-999.25), 0xBA831800)
Exemplo n.º 10
0
 def test_12_p(self):
     """TestRepCodeTo68Python.test_12_p(): to68() +1e40 is max Python."""
     self.assertEqual(pRepCode.to68(+1e40),
                      pRepCode.to68(RepCode.maxValue(68)))
Exemplo n.º 11
0
 def test_03_p(self):
     """TestRepCodeTo68Python.test_03__(): to68(0.0) -> 0x40000000 Python."""
     self.assertEqual(pRepCode.to68(0.0), 0x40000000)
Exemplo n.º 12
0
 def test_02_p(self):
     """TestRepCodeTo68Python.test_02_p(): to68(-153.0) -> 0xBBB38000 Python."""
     self.assertEqual(pRepCode.to68(-153.0), 0xBBB38000)
Exemplo n.º 13
0
 def test_01_p(self):
     """TestRepCodeTo68Python.test_01_p(): to68(153.0) -> 0x444C8000 Python ."""
     self.assertEqual(pRepCode.to68(153.0), 0x444C8000)
Exemplo n.º 14
0
 def time_pRepCode_to(self):
     pRepCode.to68(153.0)
Exemplo n.º 15
0
 def test_to_minus_153_p(self):
     """TestRepCodeToFrom68CPython.test_02_c(): to68(0xBBB38000) -> -153.0 CPython."""
     result = pRepCode.to68(-153.0)
     self.assertEqual(result, 0xBBB38000)