When using ROUND(104.6146,2) - it comes out 104.61 (?)
When using ROUND(104.6146,3) - it comes out 104.615
When using ROUND(104.615,2) - it comes out 104.62
Same behavior in EXCEL with currency formatting and
changing decimal values from 2 to 3.
This seems inconsistent to me. The first one should be
104.62...This comes from a penny rounding debate with a customer -
I withdraw the question...
I can see how the "46" is less than "50" - so that the
first one could ROUND as 104.61...
Why am I working on Saturday on stuff like this?
>--Original Message--
>When using ROUND(104.6146,2) - it comes out 104.61 (?)
>When using ROUND(104.6146,3) - it comes out 104.615
>When using ROUND(104.615,2) - it comes out 104.62
>Same behavior in EXCEL with currency formatting and
>changing decimal values from 2 to 3.
>This seems inconsistent to me. The first one should be
>104.62...
>.
>|||These are consistent - if the next digit is 5 or greater round will =round the last significant digit you are requesting UP, otherwise it =will be rounded down. To get the behaviour you want ypou couyld have a =look at the ceiling functionin BOL.
Mike John
"Steve Z" <szlamany@.antarescomputing.com> wrote in message =news:008301c3b69e$5928a5f0$a301280a@.phx.gbl...
> When using ROUND(104.6146,2) - it comes out 104.61 (?)
> When using ROUND(104.6146,3) - it comes out 104.615
> When using ROUND(104.615,2) - it comes out 104.62
> > Same behavior in EXCEL with currency formatting and > changing decimal values from 2 to 3.
> > This seems inconsistent to me. The first one should be > 104.62...|||In SQL Server, ROUND(x,n) rounds x up or down to the nearest n decimal
places.
104.6146 is closer to 104.61 than 104.62 so the value is rounded down.
If you always want to round upwards (for positive values only):
ROUND(x+0.004,2)
--
David Portas
--
Please reply only to the newsgroup
--
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment