import decimal


def _decimal2string(d):
	"""Format a decimal to a  human readable string."""
	# https://stackoverflow.com/questions/11227620/drop-trailing-zeros-from-decimal/18769210#18769210
	normalized = d.normalize()
	sign, digits, exponent = normalized.as_tuple()
	if exponent > 0:
		normalized =  decimal.Decimal((sign, digits + (0,) * exponent, 0))
	
	out = "{}".format(normalized)
	return out