.. _int_to_bytes:

	Converts the ``int`` ``int_`` to a ``bytes`` object.
	``len(result) == width``.

	If ``width`` is None, a number of bytes that is able to hold the
	number is choosen, depending on ``int_.bit_length()``.

	See also: bytes_to_int_

def int_to_bytes(int_, width = None):
	"""
	.. _int_to_bytes:

	Converts the ``int`` ``int_`` to a ``bytes`` object.
	``len(result) == width``.

	If ``width`` is None, a number of bytes that is able to hold the
	number is choosen, depending on ``int_.bit_length()``.

	See also: bytes_to_int_
	"""
	if(width == None):
		width = int_.bit_length()
	byts = math.ceil(width / 8)
	return bytes([ (int_ >> (shift * 8)) & 0xff for shift in range(byts)])