- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
I thought that it was 2n-1, so a pentastate would be 9 possible values.
Admin
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
Admin
Would the "values" of a pentastate be referred to as "exits"?
Admin
That's inspired
Admin
For performance sake, they should have used UNION ALL.
Admin
What kind of database is that? It certainly is not oracle. Is it mysql? SQL Server?
Admin
Not MySQL, nor is it Sqlite, and I think I can rule out postgresql.
Admin
Actually the value of 42 should be 42 and we can't leave out this little gem: 43 | No Quack
Admin
With trinary computers we will get that choice automatically!
Admin
You forgot about adorable little Bobby Tables!
Admin
Since 3 of the 5 are not supported, this is, in fact, a boolean.
(Not this again)
Admin
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.
Admin
No. Because 2 of them are not supported. Try to keep up...
Admin
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
Admin
Admin
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!
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.
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 dakkaAdmin
I thought Pentastate Boolean was a minor character cut from the third Star Wars movie.
Admin
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 ;)
Admin
Yeah, especially the last one... Mmmmmmmm, teapot...
Admin
Admin
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).
Admin
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).
Admin
Win! Ok everybody, you can go home now. He just won the internets... Nothing to see here.
Admin
Butthurt? You mad?
Admin
I don't know what is worse, that you have written this or that I not only understand but pmsl when I read it?
Admin
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".
Admin
131125: It is pitch black. 7798785: You have been eaten by a grue!
If you wonder why these ids, see here for an explanation.
Admin
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
Admin
Shouldn't localized strings be stored as well?
Admin
Admin
... and it requires a registry search to implement.
Admin
After so much articles on boolean related jokes, I have to say I'm bored.
Admin
Admin
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?
Admin
I like it!
Objective-C edition:
Admin
Somebody's trying to get a featured comment by being lamebly long.
Admin
Admin
And a pentagram boolean would have 666.
Admin
Clbuttic!
Admin
I have memed your memes. Pray I don't meme them any further.
On second thought: VB is TRWTF.
Admin
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.
Admin
-1: I know you know they just don't have a proof.
Admin
But what about the Irish Girl?
Admin
Anyone in for perl "0 but true" return value?
http://stackoverflow.com/questions/129945/what-does-0-but-true-mean-in-perl
Admin
47 | bazinga 48 | eats shoots and leaves 49 | eats, shoots, and leaves
Admin
The code featured in this article is certainly well-written. That doesn't make it okay.
Admin
inb4: all your meme are belong to me
69 | Yes please 1189998819991197253 | Help!!! 1189998819991197254 | Taking too long, email instead
Admin
Admin
FTFY
Admin
Yep, they really limited it. The should have named it "usp_GetYesNoAndAnyOtherRelevantOptions".