import math


def _int_width(value):
	"""Calculate the number of bits required to represent *value*."""
	if value < 0:
		raise ValueError('value must be a positive integer')
	if value == 0:
		return 1
	return math.floor(math.log(value, 2)) + 1