Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 1234»»»

AND & OR Expand / Collapse
Author
Message
Posted Tuesday, October 13, 2009 10:40 PM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Thursday, December 11, 2014 5:11 AM
Points: 654, Visits: 267
Comments posted to this topic are about the item AND & OR
Post #802511
Posted Wednesday, October 14, 2009 1:24 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Thursday, December 18, 2014 11:52 PM
Points: 459, Visits: 284
Tricky question especially in the morning


Kindest Regards,

Damian Widera
SQL Server MVP,
MCT, MCSE Data Platform, MCSD.NET
Post #802546
Posted Wednesday, October 14, 2009 2:13 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Tuesday, November 25, 2014 6:06 AM
Points: 1,865, Visits: 594
arghh!! I spent a few minutes playing with a spreadsheet to mock up the bitwise AND and OR functions (a happy little diversion) and i missed the data type gotcha!

ah well...


Life: it twists and turns like a twisty turny thing
Post #802559
Posted Wednesday, October 14, 2009 2:41 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, January 24, 2013 9:59 PM
Points: 1,354, Visits: 1,299
I just did the same thing -- missed the bit datatype.

120 = 01111000
030 = 00011110
040 = 00101000

120 and 30 = 11000 in binary or 8 + 16 = 24
24 or 40 = 11000 or 101000 = 111000 = 8 + 16 + 32 = 56

Well, all that work was thrown out the window because of the bit datatype.

I'm getting tired of these trick questions. The title of the question says AND & OR and that led me to believe the author is testing our binary skills -- not our visual acuity. We have a list of variables that are all INT except one that's squeezed in the middle. Sheesh.
Post #802568
Posted Wednesday, October 14, 2009 3:23 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Friday, May 9, 2014 12:47 AM
Points: 3,448, Visits: 4,407
I am disappointed with the question, too.
If I copied the script into SSMS, I would get the right answer. Instead, I took a piece of paper and wrote binary 'ones' and 'zeroes'... and didn't notice the 'bit' trick...
Post #802584
Posted Wednesday, October 14, 2009 3:24 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Wednesday, October 9, 2013 5:08 AM
Points: 1,123, Visits: 603
I completely agree with this, though I was this time lucky I found the bit this time. But this is not testing for knowledge about the meaning of bitwise comparising, which can be very useful.

Ronald Hensbergen

Help us, help yourself... Post data so we can read and use it: http://www.sqlservercentral.com/articles/Best+Practices/61537/
-------------------------------------------------------------------------
2+2=5 for significant large values of 2
Post #802586
Posted Wednesday, October 14, 2009 3:36 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Wednesday, June 11, 2014 9:54 AM
Points: 912, Visits: 654
Absolutely ridiculous!

What is the point of a trick question on a technical forum?
Maybe you could argue that as developers we need to pay attention to the smallest detail, but that's a pretty thin argument when we're coming here to challenge our knowledge, not our powers of observation.

A question about AND and OR is good, working out the answer is a pleasant diversion, discovering that it wasn't a question about AND or OR at all but rather an exercise in hiding the word 'bit' amongst a list of 'int's and seeing who noticed... really disappointing, to the point of making me angry!

I'm sorry - I know people put effort into making up the questions and they could have a legitimate point that I have no right to complain when I don't submit questions of my own, but this is just annoying.
Post #802599
Posted Wednesday, October 14, 2009 3:57 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Wednesday, October 9, 2013 5:08 AM
Points: 1,123, Visits: 603
hodgy (10/14/2009)
arghh!! I spent a few minutes playing with a spreadsheet to mock up the bitwise AND and OR functions (a happy little diversion) and i missed the data type gotcha!

ah well...

I hope you know about the Excel functions DEC2BIN and BIN2DEC (from Analysis Toolpak)...


Ronald Hensbergen

Help us, help yourself... Post data so we can read and use it: http://www.sqlservercentral.com/articles/Best+Practices/61537/
-------------------------------------------------------------------------
2+2=5 for significant large values of 2
Post #802605
Posted Wednesday, October 14, 2009 4:28 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Monday, November 10, 2014 9:11 AM
Points: 1,155, Visits: 1,055
vk-kirov (10/14/2009)
I am disappointed with the question, too.
If I copied the script into SSMS, I would get the right answer. Instead, I took a piece of paper and wrote binary 'ones' and 'zeroes'... and didn't notice the 'bit' trick...


Not only a trick question, but one that is possible to get right by getting the reasoning all wrong...

If you don't know that AND and OR operate bitwise on integers, you might assume that it works like Excel's AND() function which treats nonzero values as TRUE and zeroes as FALSE. Then it would return 1 as the value, even if all the variables were declared as INT.

So you'd get the right answer, but for the wrong reason - and you'd go away "knowing" something about these operators that "ain't so".

Post #802617
Posted Wednesday, October 14, 2009 4:54 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Thursday, May 15, 2014 8:37 PM
Points: 589, Visits: 2,437
I think that was a nice question because it practices the capacity to get the details: sometimes, I make error (well it does not append that often ) and can look for them for a long time, missing the detail ...
Post #802632
« Prev Topic | Next Topic »

Add to briefcase 1234»»»

Permissions Expand / Collapse