特别舍入
Special Rounding
如何将价格值四舍五入到所需的结果,当使用四舍五入时它会给我不同的结果而且上限也不同!
select ceiling(price)
-------------------------------------------------------------------------
| test following numbers as inputted price value | Is my desired Output |
| INPUT | OUTPUT |
-------------------------------------------------------------------------
| 879999.51357924604783137 | 880000 |
| 879999.50720242608036391 | 880000 |
| 879999.47819604919865821 | 880000 |
| 879999.49455676516329704 | 880000 |
| 880000.5 | 880000 |
-------------------------------------------------------------------------
Ceiling returns等于或大于值
的整数
SELECT ceiling(879999.51357924604783137)
round(X,N) 四舍五入到 N 位:
N > 0:四舍五入到小数点右边N位。
N = 0:四舍五入到最接近的整数。
N < 0:四舍五入到小数点左边N位.
然后
select cast(round(879999.51357924604783137,-1) as decimal(18,0))
select cast(round( 880000.5,-1) as decimal(18,0))
如何将价格值四舍五入到所需的结果,当使用四舍五入时它会给我不同的结果而且上限也不同!
select ceiling(price)
-------------------------------------------------------------------------
| test following numbers as inputted price value | Is my desired Output |
| INPUT | OUTPUT |
-------------------------------------------------------------------------
| 879999.51357924604783137 | 880000 |
| 879999.50720242608036391 | 880000 |
| 879999.47819604919865821 | 880000 |
| 879999.49455676516329704 | 880000 |
| 880000.5 | 880000 |
-------------------------------------------------------------------------
Ceiling returns等于或大于值
的整数SELECT ceiling(879999.51357924604783137)
round(X,N) 四舍五入到 N 位:
N > 0:四舍五入到小数点右边N位。
N = 0:四舍五入到最接近的整数。
N < 0:四舍五入到小数点左边N位.
然后
select cast(round(879999.51357924604783137,-1) as decimal(18,0))
select cast(round( 880000.5,-1) as decimal(18,0))