Conditions | 3 |
Total Lines | 14 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import struct |
||
10 | def byte_swap_32_bit(x): |
||
11 | x_type = type(x) |
||
12 | if x_type is float: |
||
13 | x = struct.unpack('>I', struct.pack('>f', x))[0] |
||
14 | |||
15 | a = ((x >> 8) & 0x00FF0000) |
||
16 | b = ((x << 8) & 0xFF000000) |
||
17 | c = ((x >> 8) & 0x000000FF) |
||
18 | d = ((x << 8) & 0x0000FF00) |
||
19 | |||
20 | if x_type is float: |
||
21 | return struct.unpack('>f', struct.pack('>I', b | a | d | c))[0] |
||
22 | else: |
||
23 | return b | a | d | c |
||
24 | |||
46 |