为什么没有这个
select round(17 * .235, 2), round(17 * (1-.235), 2)
返回
4.00和13.00
而不是
4.00和13.01
此外,
select CONVERT(Decimal(19,2), 17 * .235), CONVERT(Decimal(19,2), 17 * (1-.235))
返回
4.00和13.01
如何强制两个计算加起来(17.00)?
答案 0 :(得分:0)
with open('24june_bx.txt', 'w') as f:
for tweet in results:
try:
f.write('{}\n'.format(tweet.text.encode("utf-8")))
except UnicodeEncodeError as e:
print(e)
返回
select cast(17 * .235 as float)
,cast(17 * (1-.235) as float)
,cast(17 * .235 as float)+cast(17 * (1-.235) as float)
如果你不喜欢漂浮,请尝试小数(有些人讨厌浮动,我不是那么多)
(No column name) (No column name) (No column name)
3.995 13.005 17
答案 1 :(得分:0)
我认为答案是SQL将AWAY从零开始。这与VB的舍入(ROUND TOWARDS EVEN)不同。至少那是我读这个的方式: http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/sql-server-rounding-methods/