• Scott (unregistered) in reply to trwtf
trwtf:
Jay:
tim:
sorry guys, fact is stranger than fiction:

http://msdn.microsoft.com/en-us/library/aa432714(office.12).aspx

As there are 5 possible values, shouldn't it be a "pentastate boolean"?

No, a pentastate boolean would have seven possible values.

I thought that it was 2n-1, so a pentastate would be 9 possible values.

• Joe (unregistered) in reply to Scott

For completeness, an N-state boolean should have N!-1 possible values. This is to ensure that it can represent all nontrivial sequences of responses, so you can store YesNoNoYesYes as a single pentastate boolean.

A bistate would have 1 possible value A tristate would have 5 A quadstate would have 23 and the pentastate boolean would have 119.

--Joe

• trwtf (unregistered) in reply to Joe
Joe:
For completeness, an N-state boolean should have N!-1 possible values. This is to ensure that it can represent all nontrivial sequences of responses, so you can store YesNoNoYesYes as a single pentastate boolean.

A bistate would have 1 possible value A tristate would have 5 A quadstate would have 23 and the pentastate boolean would have 119.

--Joe

Would the "values" of a pentastate be referred to as "exits"?

• Gary (unregistered) in reply to Joe
Joe:
For completeness, an N-state boolean should have N!-1 possible values. This is to ensure that it can represent all nontrivial sequences of responses, so you can store YesNoNoYesYes as a single pentastate boolean.

A bistate would have 1 possible value A tristate would have 5 A quadstate would have 23 and the pentastate boolean would have 119.

--Joe

That's inspired

• Paula (unregistered)

For performance sake, they should have used UNION ALL.

• anonymous (unregistered) in reply to trwtf

What kind of database is that? It certainly is not oracle. Is it mysql? SQL Server?

• Scott (unregistered) in reply to anonymous
anonymous:
What kind of database is that? It certainly is not oracle. Is it mysql? SQL Server?

Not MySQL, nor is it Sqlite, and I think I can rule out postgresql.

• Dr.Evil (unregistered) in reply to Bruce W
Bruce W:
42 Depends on what the definition of 'is' is 9999 Dude, what was the question?

Actually the value of 42 should be 42 and we can't leave out this little gem: 43 | No Quack

• (cs) in reply to sakasune

With trinary computers we will get that choice automatically!

• (cs) in reply to Bill P. Godfrey
Bill P. Godfrey:
Files on embedded systems! Bert Glanstrom! Wooden Table!

• (cs) in reply to Jay
Jay:
tim:
sorry guys, fact is stranger than fiction:

http://msdn.microsoft.com/en-us/library/aa432714(office.12).aspx

As there are 5 possible values, shouldn't it be a "pentastate boolean"?

Since 3 of the 5 are not supported, this is, in fact, a boolean.

(Not this again)

• Tony (unregistered) in reply to Scott
Scott:
anonymous:
What kind of database is that? It certainly is not oracle. Is it mysql? SQL Server?

Not MySQL, nor is it Sqlite, and I think I can rule out postgresql.

Its SQL Server. Though anyone whole knows a damn about SQL Server, or SQL at all, or even basic logic, just died a little bit inside.

• PRMan (unregistered) in reply to Jay
Jay:
tim:
sorry guys, fact is stranger than fiction:

http://msdn.microsoft.com/en-us/library/aa432714(office.12).aspx

As there are 5 possible values, shouldn't it be a "pentastate boolean"?

No. Because 2 of them are not supported. Try to keep up...

• nythrix (unregistered)

200: not right now 201: ask dave 202: it's raining 203: i don't know dave 204: google it 205: reserved for future boolean 206: reserved 207: special case yes

• (cs) in reply to trwtf
trwtf:
Joe:
For completeness, an N-state boolean should have N!-1 possible values. This is to ensure that it can represent all nontrivial sequences of responses, so you can store YesNoNoYesYes as a single pentastate boolean.

A bistate would have 1 possible value A tristate would have 5 A quadstate would have 23 and the pentastate boolean would have 119.

--Joe

Would the "values" of a pentastate be referred to as "exits"?

YesNoYesYesYes

• Anonymously Yours (unregistered) in reply to Bruce W

The thing I find most disconcerting isn't that this is a stored procedure in place of an enumeration table in place of just having a single bit column. It wasn't that the strings were prefixed with 'N' to return them as unicode. It isn't that it uses bigints and, as a possible result, any table set to a value from this is using 64 times as much space per dependent column per row to store what should be a bit value (or at most -if you must have foreign keys- a tinyint). No, what troubles me is they should have named the columns "OptionId" and "OptionValue" to be consistent. Naming conventions are important, people!

tim:
sorry guys, fact is stranger than fiction:

http://msdn.microsoft.com/en-us/library/aa432714(office.12).aspx

The sad thing is a boolean can only be true or false, and Microsoft should know better. I don't say that out of respect, either...

For no reason they decided that, when you're setting the value of a bit column in the "Open Table" dialog in MS SQL Enterprise Manager, you must type "true" or "false" instead of 1 or 0. Any other value results in an error. Someone just up and decided that was the way it should be. This was apparently never communicated, because this behavior is unique to the "Open Table" dialog. If you're using a SQL statement to set that same bit, any value besides 0 or 1 results in an error. There is no recognized environmental constant named 'true' or 'false' nor will it convert literal strings of those words into bits.

Hm. Maybe they shouldn't/ know better than to define an enumeration and call it a boolean.

Bruce W:
42 Depends on what the definition of 'is' is
43: Yes and no 44: Yes or no ... 1337: C'mon, that was so late 1990's. ... 1944: NUTS ... (2^63) - 1: Still needs more dakka
• (cs) in reply to Gary
Gary:
Joe:
For completeness, an N-state boolean should have N!-1 possible values. This is to ensure that it can represent all nontrivial sequences of responses, so you can store YesNoNoYesYes as a single pentastate boolean.

A bistate would have 1 possible value A tristate would have 5 A quadstate would have 23 and the pentastate boolean would have 119.

--Joe

That's inspired

I thought Pentastate Boolean was a minor character cut from the third Star Wars movie.

• SeySayux (unregistered)

403: Forbidden 404: Not Found 413: Request Entity Too Large 416: Requested Range Not Satisfiable 417: Expectation Failed 418: I'm a teapot

I'd just love to see some of these on underwear ;)

• by (unregistered) in reply to SeySayux
SeySayux:
403: Forbidden 404: Not Found 413: Request Entity Too Large 416: Requested Range Not Satisfiable 417: Expectation Failed 418: I'm a teapot

I'd just love to see some of these on underwear ;)

Yeah, especially the last one... Mmmmmmmm, teapot...

• (cs) in reply to SeySayux
SeySayux:
403: Forbidden 404: Not Found 413: Request Entity Too Large 416: Requested Range Not Satisfiable 417: Expectation Failed 418: I'm a teapot

I'd just love to see some of these on underwear ;)

Go to thinkgeek. If I recall, they do have some of those on underwear (with customer action shots).

• Interested Observer (unregistered) in reply to Death
Death:
Scott:
Silly, you need to move that into a table to make it more easily extensible.
`SELECT valueId, ValueContent FROM YesNoOptions;`

Exacty! You never know when business people start demanding a Maybe option.

Death:
Scott:
Silly, you need to move that into a table to make it more easily extensible.
`SELECT valueId, ValueContent FROM YesNoOptions;`

Exacty! You never know when business people start demanding a Maybe option.

Haskell has the Maybe parametric type. The Boolean type is named Bool, so, for example, the (Maybe Bool) type has the values:

(Just True) (Just False) Nothing

This is a lot handier than it might seem, since Maybe forms a functor, applicative functor, monad, etc. For example, we don't know if frits eats shit until we ask him, and asking might fail. Asking involves IO, another monad. So we ask, and the result of asking is maybe an answer. But we ignore his answer anyway, since we can smell the feces on his breath. 'return' is an injection into "any" monad -- in this case, it constructs an IO action that "contains" (Just True).

```import Control.Monad
import Data.Char
import Data.Maybe

frits_eats_shit :: IO (Maybe Bool)

putStrLn "frits, I heard that you are a shit eater.  Is that true?"
-- Just first char from line.  Nothing if empty:
(fmap listToMaybe getLine)

parse_frits_answer :: Maybe Char -> Maybe Bool
-- Assume that he is, since the evidence is so strong:
parse_frits_answer (Just a) = case (toLower a) of
'y' -> Just True
't' -> Just True
'n' -> Just True  -- Assume he is lying

```
• Interested Observer (unregistered) in reply to Death
Death:
Scott:
Silly, you need to move that into a table to make it more easily extensible.
`SELECT valueId, ValueContent FROM YesNoOptions;`

Exacty! You never know when business people start demanding a Maybe option.

Death:
Scott:
Silly, you need to move that into a table to make it more easily extensible.
`SELECT valueId, ValueContent FROM YesNoOptions;`

Exacty! You never know when business people start demanding a Maybe option.

Haskell has the Maybe parametric type. The Boolean type is named Bool, so, for example, the (Maybe Bool) type has the values:

(Just True) (Just False) Nothing

This is a lot handier than it might seem, since Maybe forms a functor, applicative functor, monad, etc. For example, we don't know if frits eats shit until we ask him, and asking might fail. Asking involves IO, another monad. So we ask, and the result of asking is maybe an answer. But we ignore his answer anyway, since we can smell the feces on his breath. 'return' is an injection into "any" monad -- in this case, it constructs an IO action that "contains" (Just True).

```import Control.Monad
import Data.Char
import Data.Maybe

frits_eats_shit :: IO (Maybe Bool)

putStrLn "frits, I heard that you are a shit eater.  Is that true?"
-- Just first char from line.  Nothing if empty:
(fmap listToMaybe getLine)

parse_frits_answer :: Maybe Char -> Maybe Bool
parse_frits_answer (Just a) = case (toLower a) of
'y' -> Just True
't' -> Just True
'n' -> Just True  -- Assume he is lying

```
• by (unregistered) in reply to Interested Observer
Interested Observer:
Death:
Scott:
Silly, you need to move that into a table to make it more easily extensible.
`SELECT valueId, ValueContent FROM YesNoOptions;`

Exacty! You never know when business people start demanding a Maybe option.

Death:
Scott:
Silly, you need to move that into a table to make it more easily extensible.
`SELECT valueId, ValueContent FROM YesNoOptions;`

Exacty! You never know when business people start demanding a Maybe option.

Haskell has the Maybe parametric type. The Boolean type is named Bool, so, for example, the (Maybe Bool) type has the values:

(Just True) (Just False) Nothing

This is a lot handier than it might seem, since Maybe forms a functor, applicative functor, monad, etc. For example, we don't know if frits eats shit until we ask him, and asking might fail. Asking involves IO, another monad. So we ask, and the result of asking is maybe an answer. But we ignore his answer anyway, since we can smell the feces on his breath. 'return' is an injection into "any" monad -- in this case, it constructs an IO action that "contains" (Just True).

```import Control.Monad
import Data.Char
import Data.Maybe

frits_eats_shit :: IO (Maybe Bool)

putStrLn "frits, I heard that you are a shit eater.  Is that true?"
-- Just first char from line.  Nothing if empty:
(fmap listToMaybe getLine)

parse_frits_answer :: Maybe Char -> Maybe Bool
-- Assume that he is, since the evidence is so strong:
parse_frits_answer (Just a) = case (toLower a) of
'y' -> Just True
't' -> Just True
'n' -> Just True  -- Assume he is lying

```

Win! Ok everybody, you can go home now. He just won the internets... Nothing to see here.

• (cs) in reply to Interested Observer
Interested Observer:
Death:
Scott:
Silly, you need to move that into a table to make it more easily extensible.
`SELECT valueId, ValueContent FROM YesNoOptions;`

Exacty! You never know when business people start demanding a Maybe option.

Death:
Scott:
Silly, you need to move that into a table to make it more easily extensible.
`SELECT valueId, ValueContent FROM YesNoOptions;`

Exacty! You never know when business people start demanding a Maybe option.

Haskell has the Maybe parametric type. The Boolean type is named Bool, so, for example, the (Maybe Bool) type has the values:

(Just True) (Just False) Nothing

This is a lot handier than it might seem, since Maybe forms a functor, applicative functor, monad, etc. For example, we don't know if frits eats shit until we ask him, and asking might fail. Asking involves IO, another monad. So we ask, and the result of asking is maybe an answer. But we ignore his answer anyway, since we can smell the feces on his breath. 'return' is an injection into "any" monad -- in this case, it constructs an IO action that "contains" (Just True).

```import Control.Monad
import Data.Char
import Data.Maybe

frits_eats_shit :: IO (Maybe Bool)

putStrLn "frits, I heard that you are a shit eater.  Is that true?"
-- Just first char from line.  Nothing if empty:
(fmap listToMaybe getLine)

parse_frits_answer :: Maybe Char -> Maybe Bool
-- Assume that he is, since the evidence is so strong:
parse_frits_answer (Just a) = case (toLower a) of
'y' -> Just True
't' -> Just True
'n' -> Just True  -- Assume he is lying

```

• Aussie Contractor (unregistered) in reply to Bill P. Godfrey

I don't know what is worse, that you have written this or that I not only understand but pmsl when I read it?

• Nome de Plume (unregistered) in reply to sakasune
sakasune:
Actually I had to do something like that...there were three possible choices and my manager demanded they be in a table...

ID | Text 1 | Yes 2 | No 3 | Unavailable

sigh

This is not that stupid. I wish more people would use discrete keys to model their data. As foreign keys, these explain other tables' rows clearly.

Suppose Text is an options menu in an online form. The user selects one rather than "Yes", "yes", or "YES".

• Design Pattern (unregistered)

131125: It is pitch black. 7798785: You have been eaten by a grue!

If you wonder why these ids, see here for an explanation.

• (cs) in reply to airdrik
We actually had an interview candidate some time ago who answered similar to this - I'm going to say No, but I'm leaning more towards Yes, or something similar.

I actually love giving answers like that. If the interviewer thinks things are black and white in this world, I don't want to work with them.

This WTF is less of a WTF than you might think. It's actually quite common, as someone mentioned, to support reporting requirements and translation of strings. Sometimes you need the values in a table so you can do joins. This is usually due to some limitation of the tools/users.

It's similar to a numbers/constants table - although these days, with SQL Server, I'm betting recursive CTEs give better performance than numbers tables.

A table of numbers or other "trivial constants" can be very useful. http://sqlserver2000.databases.aspfaq.com/why-should-i-consider-using-an-auxiliary-numbers-table.html

• Farooq (unregistered)

Shouldn't localized strings be stored as well?

• (cs) in reply to airdrik
airdrik:
To best ensure that the future will remain flexible, while still retaining usability, the schema needs to be extended with a BooleanValue field as follows:
```ID | BooleanValue | Value
0  | "False"      | "No"
1  | "False"      | "no"
2  | "False"      | "NO"
3  | "False"      | "NO!"
4  | "False"      | "NO!!"
5  | "False"      | "False"
6  | "False"      | "false"
7  | "False"      | "FALSE"
8  | "False"      | "FALSE!"
9  | "False"      | "FALSE!!"
10 | "False"      | "HECK NO!"
11 | "False"      | "Nein"
12 | "False"      | "Nao"
13 | "False"      | "Zero"
14 | "False"      | "Non"
15 | "True"       | "Yes"
16 | "True"       | "yes"
17 | "True"       | "YES"
18 | "True"       | "YES!"
19 | "True"       | "True"
20 | "True"       | "true"
21 | "True"       | "TRUE"
22 | "True"       | "TRUE!"
23 | "True"       | "HECK YES!"
24 | "True"       | "For Sure"
25 | "Maybe"      | "Maybe"
26 | "Maybe"      | "maybe"
27 | "Maybe"      | "Unavailable"
28 | "Maybe"      | "unavailable"
29 | "Maybe"      | "42"
30 | "True"       | "43"
31 | "True"       | "is"
32 | "True"       | "Is"
33 | "True"       | "IS"
34 | "False"      | "isn't"
35 | "False"      | "Isn't"
36 | "False"      | "ISN'T"
37 | "False"      | "isnt"
38 | "False"      | "Isnt"
39 | "Maybe"      | "ISNT"
40 | "True"       | "Sim"
41 | "True"       | "Ja"
42 | "False"      | "null"
43 | "False"      | "NULL"
44 | "False"      | "Null"
```

Captcha: enim - an enum which shouldn't be.

```45 | "True"      | "IS TOO!"
46 | "False"     | "IS NOT!"
47 | "True"      | "YUH-HUH!"
48 | "False"     | "NUH-UH!"
49 | "Maybe"     | "I'M TELLING!"```

• oheso (unregistered) in reply to sakasune
sakasune:
I could have used that...and I love how three of them "not supported"

... and it requires a registry search to implement.

• Cheong (unregistered)

After so much articles on boolean related jokes, I have to say I'm bored.

• Gary Olson (unregistered) in reply to Neo
Neo:
tim:
sorry guys, fact is stranger than fiction:

http://msdn.microsoft.com/en-us/library/aa432714(office.12).aspx

Excellent. A tri-state boolean with five possible values, two of which are actually supported. I think we have a winner.

One of the supported values is contrary to convention; but is the mathematical product of imaginary values from a perpendicular dimension. Two unsupported values are a product of imaginary values; and one unsupported value is a conventional binary value. Who knew Escher was also a software engineer?

• Luiz Felipe (unregistered)

I have an ideia! schrodinger TriBoolean 50% true 50% false 1% filenotfound

class schrodingerBoolean { union { long value; struct p { short percent_true; short percent_false; short percent_file_not_found; } } u; public schrodingerBoolean ( int p_true, int p_false, int p_fnotfound ) { u.p.percent_true = p_true; u.p.percent_false = p_false; u.p.percent_file_not_found = p_fnotfound; } public operator int () { if ( rand() % 100 <= u.p.percent_file_notfound ) return 666; if ( rand()%2 == 1 ) { if ( rand() % 100 <= u.p.percent_false ) return 0; if ( rand() % 100 <= u.p.percent_true ) return 1; } else { if ( rand() % 100 <= u.p.percent_true ) return 1; if ( rand() % 100 <= u.p.percent_false ) return 0; } return rand()%2; } schrodingerBoolean & operador | (const Time& lhs, const Time& rhs) { return new schrodingerBoolean ( (lhs.p.percent_false & rhs.p.percent_true), (lhs.p.percent_true & rhs.p.percent_false), (lhs.p.percent_file_not_found + rhs.percent_file_not_found)/2); } schrodingerBoolean & operador & (const Time& lhs, const Time& rhs) { return new schrodingerBoolean ( (lhs.p.percent_false | rhs.p.percent_true), (lhs.p.percent_true | rhs.p.percent_false), (max(lhs.p.percent_file_not_found, rhs.percent_file_not_found)); } bool & operador == (const Time& lhs, const Time& rhs) const { return (int)lhs == (int)rhs; } bool & operador != (const Time& lhs, const Time& rhs) const { return (int)lhs == (int)rhs; } }

int main() {

schrodingerBoolean *b, *acid;

*b = new schrodingerBoolean(20,80,5); *acid = new schrodingerBoolean(100,100,100);

b = b | acid;

if ((int)b == FILE_NOT_FOUND) { printf("something very badly was happened! the universe is blowing!"); }

if (b) { printf("the cat is dead!"); } else { printf("the cat is not dead!"); }

}

captch damnum: is some form of maldiction?

• Scott (unregistered) in reply to Luiz Felipe

I like it!

Objective-C edition:

```@inteface SchrodingerBoolean {
BOOL value = nil;
}
@end

@implementation SchrodingerBoolean
@dynamic value;
- (BOOL) value {
if (value == nil) {
value = random()>INT_MAX>>1?YES:NO;
}
return value;
}
@end
```
• (cs) in reply to Anonymously Yours
Anonymously Yours:
The thing I find most disconcerting isn't that this is a stored procedure in place of an enumeration table in place of just having a single bit column. It wasn't that the strings were prefixed with 'N' to return them as unicode. It isn't that it uses bigints and, as a possible result, any table set to a value from this is using 64 times as much space per dependent column per row to store what should be a bit value (or at most -if you must have foreign keys- a tinyint). No, what troubles me is they should have named the columns "OptionId" and "OptionValue" to be consistent. Naming conventions are important, people!
tim:
sorry guys, fact is stranger than fiction:

http://msdn.microsoft.com/en-us/library/aa432714(office.12).aspx

The sad thing is a boolean can only be true or false, and Microsoft should know better. I don't say that out of respect, either...

For no reason they decided that, when you're setting the value of a bit column in the "Open Table" dialog in MS SQL Enterprise Manager, you must type "true" or "false" instead of 1 or 0. Any other value results in an error. Someone just up and decided that was the way it should be. This was apparently never communicated, because this behavior is unique to the "Open Table" dialog. If you're using a SQL statement to set that same bit, any value besides 0 or 1 results in an error. There is no recognized environmental constant named 'true' or 'false' nor will it convert literal strings of those words into bits.

Hm. Maybe they shouldn't/ know better than to define an enumeration and call it a boolean.

Bruce W:
42 Depends on what the definition of 'is' is
43: Yes and no 44: Yes or no ... 1337: C'mon, that was so late 1990's. ... 1944: NUTS ... (2^63) - 1: Still needs more dakka

Somebody's trying to get a featured comment by being lamebly long.

• (cs) in reply to Files on embedded systems! Bert Glanstrom! Wooden Table!
Files on embedded systems! Bert Glanstrom! Wooden Table!:
Yes? What do you want?
i don't know why but that really cracked me up :) thanks!
• The 2-Belo (unregistered) in reply to Joe
Joe:
For completeness, an N-state boolean should have N!-1 possible values. This is to ensure that it can represent all nontrivial sequences of responses, so you can store YesNoNoYesYes as a single pentastate boolean.

A bistate would have 1 possible value A tristate would have 5 A quadstate would have 23 and the pentastate boolean would have 119.

And a pentagram boolean would have 666.

• Woody (unregistered) in reply to Someone You Know
Someone You Know:
SR:
Bill P. Godfrey:
Files on embedded systems! Bert Glanstrom! Wooden Table!

Irish! Girl!

Brillant?

Clbuttic!

• My Name (unregistered) in reply to Woody
Woody:
Someone You Know:
SR:
Bill P. Godfrey:
Files on embedded systems! Bert Glanstrom! Wooden Table!

Irish! Girl!

Brillant?

Clbuttic!

I have memed your memes. Pray I don't meme them any further.

On second thought: VB is TRWTF.

• Troutman (unregistered)

I read these WTF updates regularly, but really struggle to understand the coding ones, and your comments are usually way over my head. I sit there, staring at the screen, just trying to work out what is so wrong or funny about a piece of code like the one on this feature, but fail. That's all really.

• halyavin (unregistered)

-1: I know you know they just don't have a proof.

• (cs) in reply to Bill P. Godfrey
Bill P. Godfrey:
Files on embedded systems! Bert Glanstrom! Wooden Table!

But what about the Irish Girl?

• feugiat (unregistered)

Anyone in for perl "0 but true" return value?

http://stackoverflow.com/questions/129945/what-does-0-but-true-mean-in-perl

• mainframe gamer (unregistered)

47 | bazinga 48 | eats shoots and leaves 49 | eats, shoots, and leaves

• (cs) in reply to Troutman
Troutman:
I sit there, staring at the screen, just trying to work out what is so wrong or funny about a piece of code like the one on this feature, but fail.
Sometimes all that's really wrong with a piece of code is that it exists in the first place.

• /b/ (unregistered)

inb4: all your meme are belong to me

69 | Yes please 1189998819991197253 | Help!!! 1189998819991197254 | Taking too long, email instead

• (cs) in reply to Gert
Gert:
Actually to get into this seriously, for reporting purposes where you want to display a string instead of a number, this is probably the fastest way (with large recordsets).

Although I do agree that a fixed table is even more better for that, but it's quicker to join this (virtual) table then use case when's in the query. A lot of case when's make the query slow.

I hope you're trolling.

• Tumblr (unregistered) in reply to /b/
/b/:
inb4: all your meme are belong to us

69 | Yes please 1189998819991197253 | Help!!! 1189998819991197254 | Taking too long, email instead

FTFY

• (cs)

Yep, they really limited it. The should have named it "usp_GetYesNoAndAnyOtherRelevantOptions".