Пример #1
0
def test_unpack():
    for expected, size, bigendian, input in testcases:
        print "test_unpack:", expected, size, bigendian
        assert len(input) == size
        res = unpack_float(input, bigendian)
        if isnan(res) and isnan(expected):
            pass
        else:
            if size == 8:
                assert res == expected  # exact result expected
            else:
                assert res == expected or abs(res - expected) < 1e-6
Пример #2
0
def test_unpack():
    for expected, size, bigendian, input in testcases:
        print 'test_unpack:', expected, size, bigendian
        assert len(input) == size
        res = unpack_float(input, bigendian)
        if isnan(res) and isnan(expected):
            pass
        else:
            if size == 8:
                assert res == expected  # exact result expected
            else:
                assert res == expected or abs(res - expected) < 1E-6
Пример #3
0
def make_float_unpacker(size):
    return lambda fmtiter: fmtiter.appendobj(ieee.unpack_float(
        fmtiter.read(size),
        fmtiter.bigendian))
Пример #4
0
def unpack_float(s):
    return ieee.unpack_float(s, False)
Пример #5
0
def unpack_float(s):
    return ieee.unpack_float(s, False)
Пример #6
0
def make_float_unpacker(size):
    return lambda fmtiter: fmtiter.appendobj(
        ieee.unpack_float(fmtiter.read(size), fmtiter.bigendian))