Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/pyasn1/compat/binary.py: 17%
18 statements
« prev ^ index » next coverage.py v7.2.2, created at 2023-03-26 06:25 +0000
« prev ^ index » next coverage.py v7.2.2, created at 2023-03-26 06:25 +0000
1#
2# This file is part of pyasn1 software.
3#
4# Copyright (c) 2005-2019, Ilya Etingof <etingof@gmail.com>
5# License: http://snmplabs.com/pyasn1/license.html
6#
7from sys import version_info
9if version_info[0:2] < (2, 6):
10 def bin(value):
11 bitstring = []
13 if value > 0:
14 prefix = '0b'
15 elif value < 0:
16 prefix = '-0b'
17 value = abs(value)
18 else:
19 prefix = '0b0'
21 while value:
22 if value & 1 == 1:
23 bitstring.append('1')
24 else:
25 bitstring.append('0')
27 value >>= 1
29 bitstring.reverse()
31 return prefix + ''.join(bitstring)
32else:
33 bin = bin