def Builtin_ROUND(expr, ctx):
"""
http://www.w3.org/TR/sparql11-query/#func-round
"""
# This used to be just math.bound
# but in py3k bound was changed to
# "round-to-even" behaviour
# this is an ugly work-around
l = expr.arg
v = numeric(l)
v = int(Decimal(v).quantize(1, ROUND_HALF_UP))
return Literal(v, datatype=l.datatype)
评论列表
文章目录