October 4, 2016 at 9:10 pm
Comments posted to this topic are about the item Rounding Parameters
October 5, 2016 at 12:16 am
This was removed by the editor as SPAM
October 5, 2016 at 2:48 am
Stewart "Arturius" Campbell (10/5/2016)
Now that is interesting.Have never used a third parameter with ROUND before.
thanks for the question, Steve
Indeed! Learned something new with that one. Thanks
October 5, 2016 at 5:22 am
I've never used the third parameter either. Nice question.
October 5, 2016 at 6:25 am
Very interesting.
A little additional research shows that the 3rd parameter can be anything other than the default of zero will cause the round function to truncate at the location specified by the 2nd parameter.
SELECT ROUND(2305.6664, 1, 1) has the same result.
Isn't safe to say that the use of a 3rd parameter actually converts the ROUND function into a TRUNCATION function ?;-)
October 5, 2016 at 8:13 am
!
--------------------------------------
;-)“Everything has beauty, but not everyone sees it.” ― Confucius
October 5, 2016 at 9:15 am
There's more to ROUND than I thought.
October 5, 2016 at 11:06 am
Nice, Steve, very nice. Thank you!
October 5, 2016 at 11:20 am
Budd (10/5/2016)
Very interesting.A little additional research shows that the 3rd parameter can be anything other than the default of zero will cause the round function to truncate at the location specified by the 2nd parameter.
SELECT ROUND(2305.6664, 1, 1) has the same result.
Isn't safe to say that the use of a 3rd parameter actually converts the ROUND function into a TRUNCATION function ?;-)
Hi Budd
Yes, that's truncation, which is written in the description of the third argument
of the ROUND function in the MSDN ROUND (T-SQL). The function TRUNCATION not exists
in T-SQL, but it is in the Data Analysis Expressions (DAX) Reference,
see https://msdn.microsoft.com/en-us/library/ee634907.aspx
Furthermore, I want to thank Steve for a simple, but pragmatical question.
October 5, 2016 at 3:23 pm
It's a good question, straightforward, no ambiguities, very easy of us for those of us who know the full functionality of ROUND and trivial to research for anyone else (the documentation for functions like this is very easy to find and, except perhaps for a couple of oddball cases. both correct and very easy to understand).
What I find hard to understand is why the third parameter wasn't a a choice between 0 and 1 instead of allowing more than 4 billion values all meaning the same as 1. I guess there is some explanation for such a bizarre design decision, but I've no idea what it could be. Given that the thrd parameter exists, it probably ought to provide more options than just 0 (round to nearest, however that's currently defined) and non-0 (round towards 0, also known as truncate) - for example round away from 0 is sometimes useful, as is round up (round away away from 0 on positive and towards 0 on negative), round down (towards 0 on positive and away from 0 on negative) and then there are at least 4 different rules for how a final 5s are to be handled in round to nearest, which makes at least 8 different rounding functions (and perhaps there are more, I don't claim that the ones I've seen are all there are) that have been used in various applications in the last 60 years.
Tom
October 6, 2016 at 1:41 am
Nice one, thanks.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply