SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


AND & OR


AND & OR

Author
Message
VM-723206
VM-723206
SSC Eights!
SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)

Group: General Forum Members
Points: 826 Visits: 267
Comments posted to this topic are about the item AND & OR
Damian Widera-396333
Damian Widera-396333
Mr or Mrs. 500
Mr or Mrs. 500 (530 reputation)Mr or Mrs. 500 (530 reputation)Mr or Mrs. 500 (530 reputation)Mr or Mrs. 500 (530 reputation)Mr or Mrs. 500 (530 reputation)Mr or Mrs. 500 (530 reputation)Mr or Mrs. 500 (530 reputation)Mr or Mrs. 500 (530 reputation)

Group: General Forum Members
Points: 530 Visits: 321
Tricky question especially in the morning :-D

Kindest Regards,

Damian Widera
SQL Server MVP,
MCT, MCSE Data Platform, MCSD.NET
hodgy
hodgy
SSCrazy
SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)

Group: General Forum Members
Points: 2207 Visits: 596
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

cengland0
cengland0
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1894 Visits: 1300
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.
vk-kirov
vk-kirov
Hall of Fame
Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)

Group: General Forum Members
Points: 3912 Visits: 4408
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...
Ronald H
Ronald H
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1366 Visits: 623
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
dave.farmer
dave.farmer
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1253 Visits: 792
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.
Ronald H
Ronald H
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1366 Visits: 623
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
archie flockhart
archie flockhart
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1378 Visits: 1156
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".
tilew-948340
tilew-948340
SSC Eights!
SSC Eights! (867 reputation)SSC Eights! (867 reputation)SSC Eights! (867 reputation)SSC Eights! (867 reputation)SSC Eights! (867 reputation)SSC Eights! (867 reputation)SSC Eights! (867 reputation)SSC Eights! (867 reputation)

Group: General Forum Members
Points: 867 Visits: 2437
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 :heheSmile and can look for them for a long time, missing the detail ...
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search