|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Friday, September 03, 2010 4:19 AM
Points: 158,
Visits: 72
|
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Monday, June 10, 2013 1:20 PM
Points: 2,163,
Visits: 2,149
|
|
Nice question, thanks!
Though I think the explanation left a little to be desired. It isn't just that the decimal type was used, it was that the decimal type was used and no precision/scale was specified, so the number got rounded down to 1.0 when it was converted.
For example this results in the same thing as all of your float examples:
select Ceiling(convert(decimal(2, 1), 1.09)) Because with a scale of one specified it gets rounded to 1.1 before it goes to ceiling.
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Today @ 10:23 AM
Points: 1,381,
Visits: 4,859
|
|
Knew the answer but had a brain fart and clicked the wrong option, oops!
UMG Developer is right about the explanation.
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Thursday, June 06, 2013 6:20 AM
Points: 1,350,
Visits: 434
|
|
Good question but I think a better explaination is: the default of decimal without parameters is (18,0) thus making 1.09 -> 1 and then the ceiling of 1 is 1
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Thursday, April 18, 2013 5:41 AM
Points: 71,
Visits: 49
|
|
| Thank you Old Hand. I knew the ceiling function brought you up to the next integer, but I couldn't figure out why the decimal was any different than the float on this one! You're explanation was what I was missing. For some reason I thought the default precision was 2, not 0. I'll be sure to remember that the next time I use a decimal data type.
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Today @ 10:23 AM
Points: 1,381,
Visits: 4,859
|
|
I hope one thing that everybody has learned from these questions is that you should never rely on default precision for anything - you will inevitably get it wrong sooner or later
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 5:53 PM
Points: 7,179,
Visits: 7,276
|
|
Good question, but as some have already noted the explanation is a bit lacking.
Also, the question was made too easy by the absence of the All 2s option as an answer choice - anyone who knows what ceiling means can eliminate all answers but the correct one with knowing anything at all about decimal or its default precision.
Tom Is minic a gheibheann béal oscailte dorn dúnta. Is minig a cheapas beul fosgailte dòrn dùinte.
http://es.linkedin.com/in/tomthomsonsoftware
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Thursday, June 13, 2013 11:45 AM
Points: 3,417,
Visits: 3,435
|
|
Tom.Thomson (11/2/2010) Good question, but as some have already noted the explanation is a bit lacking.
Also, the question was made too easy by the absence of the All 2s option as an answer choice - anyone who knows what ceiling means can eliminate all answers but the correct one with knowing anything at all about decimal or its default precision.
Yes, I agree. The best wrong answer was missing.
|
|
|
|
|
SSCoach
         
Group: General Forum Members
Last Login: Today @ 10:09 PM
Points: 18,848,
Visits: 12,433
|
|
|
|
|
|
SSCrazy Eights
        
Group: General Forum Members
Last Login: Today @ 2:54 AM
Points: 9,409,
Visits: 6,494
|
|
|
|
|