四舍五入十进制数 [英] Rounding off decimal number
本文介绍了四舍五入十进制数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,我在我的程序中有以下代码,它工作正常,除非运行时它给我例如1.127790001的值,而我只希望它四舍五入到小数点后一位,如1.1278 .....任何想法如何会吗谢谢
Hello I have following code in my procedure it works fine except when i run it it gives me value of for example 1.127790001 while i just want it to round off upto four decimal point like 1.1278..... any ideas how to do it? Thanks
SET @tg=Cast (@tr as numeric (7,4))*Cast (@tg as numeric(7,4))+Cast(@tg as numeric (7,4))
Select @tg
推荐答案
试试这个:
Try this one:
DECLARE @num DECIMAL(7,4)
SET @num = 1.1234567
SELECT @num
这将显示 1.1234
如果这解决了您的问题,请标记为答案
最好的问候,
爱德华(Eduard)
This will display 1.1234
Please mark as answer if this solved your problem
Best regards,
Eduard
使用Round函数
Use Round function
PRINT ROUND(1.127790001,4)
使用以下Systax:
Use the following Systax :
ROUND ( numeric_expression , length [ ,function ] )
例子:
Example :
SELECT ROUND(123.9994, 3), ROUND(123.9995, 3)
GO
这篇关于四舍五入十进制数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文