- 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
"management had removed cubicle walls (to "facilitate communication")"
TRWTF
TWTF from which all other WTFs flow.
Admin
Admin
I... I just.... I can't even comprehend how someone produces this...
Admin
I think I can help with this: if(userCanDownload != true && file != null || userCanDownload != false) is the same as if( ( ! userCanDownload && file != null ) || userCanDownload) in English... if ( ( user not allowed to download and file is there ) or (OK to download) )
Soooooooo.... If the user is NOT allowed to download, and the file is there, then the button is ON and they ARE allowed to download it.
(And if they do have the authority to download the file, then it doesn't matter if a file is there or not, the download button is also shown.)
.
But what I really wanted to know was... Who put this crazy nonsense into the program?!?
Admin
The joke is that if we assume that the code make sense, then the boolean must be tri-state because otherwise testing it explicit for both true and false make no sense.
Admin
Shell script languages work similarly.
(command1) || (command2) - if (command1) yields 0 (success), stop. Otherwise, execute (command2).
(command1) && (command2) - if (command1) yields anything other than 0 (failure), stop. Otherwise, execute (command2).
But it seems they don't have any precedence of && over ||. (I tried Linux bash and Windows cmd.exe)
Admin
Admin
And of course, file == null is another way to say FILE_NOT_FOUND, so it's harkening back to the classic tri-state as well.
I'm surprised nobody's found my hidden joke yet. I guess that means I win?
Admin
Word to the wise: Make a photocopy of page 53 of K&R, Table 2-1 and post it prominent place in your cubicle. It will serve you well. If you program in other languages, I am sure that they have similar tables.
Admin
It's not really a page long, but:
[image]Admin
I just saw my reflection in my monitor while looking at this code. I saw myself making the WTF face from this site's logo. Now I can't stop laughing at it and myself.
Admin
It wasn't a good joke, though.
Admin
Normally the preview of an article gives a clue whether it's worth reading or not. This one was:
It tells me nothing, almost like clickbait. I only read it to find WTF the WTF was about. So TRWTF is the article preview.
(Shit. This was supposed to be a reply to the topic, not a comment.)
Admin
Which brings us to an interesting question. Versions of C newer than C89 may have resolved this question, and if so, so much the better. What is the portable range of the member
x
in this struct?And the answer is: [0,0] Why? (Hint: it has nothing to do with the question of one's versus two's versus s-and-m.)
Re: One's complement architectures and their continued appearance in lectures on integer representations decades after decades after their disappearance. I was at university three decades ago, and yes, I used a one's complement machine at that time.
http://en.wikipedia.org/wiki/CDC_Cyber
And sign-and-magnitude is still worth studying, in the context of floating point representations, because that's what the mighty IEEE-754 uses for the mantissa. (IBM System/360 and successors use sign-and-magnitude as well, but hexadecimal rather than binary...)
Admin
Since hexadecimal is just using 4 bits per hex digit, that's not strange at all. (I thought they used decimal, which is quite a bit stranger except when it comes to handling financial transactions…)
Admin
It is a bit larger than that. Personally I blow up the table to a full page, and it is visible from a distance. Something I need to accommodate my advancing age (SIGH).
Admin
Admin
I have asked this one. It's good for getting to see if someone understands what goes on behind the scenes and what the issues are.
(You could also, but not quite as valuably, ask why you should never throw exceptions in a C++ destructor...)
Admin
You realise Wikipedia articles are worthless without citations? I think most of us will have seen wtfs in Wikipedia articles.
Admin
||
has additive flavor and&&
multiplicative, and (in most programming languages) it's reflected in their precedences. If you don't see that, you don't know the first thing about boolean algebras.Admin
They are far from worthless. You have to read them and understand them and then exercise your judgement, but that's true of every written word ever.
Admin
[Citation needed]
Admin
Filed Under: inb4 bots don't work on article topics
Admin
that.
Admin
I'm aware. Just pretend @trwtfbot posted. Or don't if you don't like bots...
Admin
Of course Admins can download any files that don't exist! Yesterday I downloaded a how-to book on tachyon propulsion systems.
Admin
Hiere follows just the mandatory reminiscence of
Edti: Maybe I could mention that Jabberwacky once answered this with
Edti 2:
Are you sure you willan donedn't download it tomorrow?Edti n+1:
But I've learned that Boolean algebras were symmetric (self-dual) under swapping truthiness and falsiness (or whatever you call them) and the operators that are used to be called && and || in programming.
Edti n+2:
Where's the problem as long as you use it in the constructor?Admin
If we're having tri-state booleans, which three states are we talking about? NY, NJ and Connecticut? Indiana, Illinois and Kentucky? California, Oregon and Nevada? According to Wikipedia, there are 62 of the silly things!
http://en.wikipedia.org/wiki/Tri-state_area#Land
Admin
Have you tried it? Using your struct, I tried:
Fun exercise. Thanks for the stimulating conversation.
Admin
Who says they're even states of the United States? India, Mexico, Brazil and probably other countries are also composed of subdivisions called "states" (or local-language equivalents, e.g., "estados").
Admin
BRTFY
Admin
Hmm.
True for Fortran (precedence:
.NOT.
,.AND.
,.OR.
) and Algol (precedence: not, and, or, implies, equivalent – a bit more complex) and their various siblings and offsprings.Not true for C and most of the modern languages introduced since the 1980s. These use "short circuit evaluation" rather than true Boolean algebra. Implementation: Evaluate from left to right. In case of or, return current left-hand value, if it evaluates to
true
, else proceed. In case of and, return current left-hand value, if it evaluates tofalse
, else proceed. Return value of last element, if we have not returned earlier. (not always binds deeper.)Just because there is such a thing as Boolean algebra, it doesn't mean it's actually used by computer languages. Popular examples to the contrary: C, C++, JS, Perl, PHP, etc, etc, ... Most of the code actually run on a computer today doesn't adhere to it.
[Edit:] It should be noted that with Fortran, Algol and the like the entire Boolean expression is always evaluated (no undefined states here), while in short-circuit evaluation the processing of the whole expression and all its terms is merely an edge-case (which actually allows for some kind of tristate logic as in undefined states in the parts that are not executed – these hidden tristate-like characteristics are also a major cause of failure). We may also note that in the original implementation of Fortran with arithmetic if being the only construct for branching, conditions were always of trinary logic (less than zero, zero, greater zero). True Boolean expressions – and Boolean algebra – were only introduced in Fortran IV.
Admin
Note that while many C-like languages return the actual left-hand or right-hand value (so you can do
config['key'] || defaults['key']
in javascript) in C (or at least gcc) these operators always return 1 or 0.Admin
Admin
That sounds like work
Admin
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf
On page 89, in §6.5.14:
So yes, it's specified to return 0 or 1, and is pretty clear as these things go. (The
&&
operator is similarly clear.)Admin
A further hint: What is the type of
int x:1
?Admin
By which, by the way, I mean "what is the fully-specified type, with no abbreviations allowed?"
unsigned
is an abbreviation ofunsigned int
, andshort
is an abbreviation forsigned short int
.Admin
And whatever your explanation for (1), you're wrong. The constructor is just about the worst possible place to do it.
And the salmon-coloured popup box can fuck the fucking fuck off.
Admin
My sense of humour works at roughly a right angle to everyone else's. I have no way of knowing what's a joke, let alone what's hidden.
I'm going to need your help to discover the secret joke.
Well now I really want to know. Help me stoke the fires of controversy.
Admin
The only thing I noticed was an HTML comment (therefore hidden) that I guess was the "joke," but I didn't think was humorous ("Danger zone."). Huh? Maybe it's an allusion to something I don't get; otherwise, either Asher is in danger because Lindsay is now ticked-off, or looking at Asher's screen is dangerous to Lindsay. I guess?
Admin
Yes
Admin
I don't see how "measurably mediocre" security is that much of a step up from the naive sense of security an organization might get from relying upon browser security. In fact, it could be less secure when you have an unsophisticated user base (as might easily exist in this article) who wouldn't even think about fishing around for such information unless you actually smacked them on the head with it.
If prices are such a sensitive issue, there shouldn't even be a pricelist button in the procurement site, let alone a button visible for one and all to see:
Admin
I work at a healthcare organization which just suffered a data theft that affected tens of thousands of patient records--and that was carried out by a couple of those "unsophisticated users".
Given sufficient nefarious motivation, some of those users can become startlingly sophisticated.
Admin
Admin
You're right! Should have added some like, "Implementation details: Some languages (like C) will return normalized scalar values (1,0)."
Admin
Again, a bug caused by comparing booleans to constants with !=. Also, an unnecessarily complex expression.
I imagine what is meant is
Anyone here want to tell me that adding an explicit comaprison to true would have any point whatever?
Admin
Ideally, there'd be three states.
But that would be a sensible approach…
Admin
now assign a label to each state:
Admin