utils.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:money-to-prisoners-send-money 作者: ministryofjustice 项目源码 文件源码
def clamp_amount(amount):
    """
    Round the amount to integer pence,
    rounding fractional pence up (away from zero) for any fractional pence value
    that is greater than or equal to a tenth of a penny.
    @param amount: Decimal amount to round
    """
    tenths_of_pennies = (amount * Decimal('1000')).to_integral_value(rounding=ROUND_DOWN)
    pounds = tenths_of_pennies / Decimal('1000')
    return pounds.quantize(Decimal('1.00'), rounding=ROUND_UP)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号