- 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
Sorry, I refuse to continue any discussion after an ad hominem attack.
Admin
I see your Boolean Truths, and I raise you a ParamValueIsTrueAsBoolean.
protected bool ParamValueIsTrueAsBoolean(string stringvalue) { return (stringvalue.Equals("J") || stringvalue.Equals("Y") || stringvalue.Equals("1") || stringvalue.Equals("j") || stringvalue.Equals("y") || stringvalue.Equals("True") || stringvalue.Equals("true")); }
Admin
Microsoft does this for the Office 2007+ data formats because it's faster to do all the conversions, so it can't be all bad.
Admin
Those are still in wide use on embedded systems (without filesystems).
What's the "advantage" of todays WTF having a value that represents both false and "not-false"? Now, how could you manage to get all three points wrong?Admin
Don't ask how I know.
Admin
The only place you would typically see this is in an academic setting. I still have professors insist I learn FORTRAN.
Admin
Best image ever. Bookmarked.
Really, when people speaking English as a second language can get this one and Americans can't, you know something has gone horribly wrong.
On topic: 'N' == True and 'N' == False ... I have no friggin' clue how I'd handle that monstrosity. Probably just try to refactor in a bit of sanity.
git checkout dev; while code fails; do refactor and fix boolean values; make; done; git checkout master; git merge dev; git commit -a -m "Fixed retarded-ass boolean crap to make some semblance of sense"; git push; get fired for wasting your time on something that works already; feel content in the knowledge that you prevented your replacement from committing suicide;
Admin
Please try again. You are only wrong by 11 years. Granted, Windows and *nix, being over 11 years old, don't use it, but it still exists.
Admin
'undef' would like to have a word with you. (To say nothing of empty arrays/hashes.)
Admin
I like PIC 9(5)V99.
Admin
TRWTF is still using C89 in 2010… (Ok, C99’s _Bool is no great improvement—it’s basically just an other unsigned int. Looks like TAWTF is C)
Admin
Sorry, slavik, but he's still right. To quote from your preferred source:
So they're still using ints, they're just calling them bools.
The code sample included makes it pretty clear, for those who aren't familiar with C:
(note the comment)
Admin
Admin
struct bit fields in c: http://www.cs.cf.ac.uk/Dave/C/node13.html#SECTION001320000000000000000
Admin
Dude, seriously Shut the F up if you don't know what you're talking about. You're as dumb as they get.
Admin
trwtf you are 100% correct about the _Bool, but by asserting there are not bool types and people only use integers, the moron is stating erroneous concepts.
Admin
You forgot undef.
Admin
Ad hominem != insult. If he had said "Your argument is wrong because you are a dumbass", that would be an ad hominem. However, he clearly listed the reasons he thought you were wrong. That is not an ad hominem, idiot.
Admin
Admin
Admin
Admin
Admin
Admin
From an ini file parser:
Admin
Reminds me of the gender codes the NZ Ministry of Health uses (which actually comes from Statistics New Zealand)
M = Male F = Female U = Unknown I = Indeterminate
Admin
I would argue that inclusion via standard library headers would qualify as being "in the language." If not, C becomes a rather useless language that doesn't even have the ability to print output to the console.
Admin
I can't quite follow your reasoning... ;-)
Admin
Logic would like to have a word with you: http://en.wikipedia.org/wiki/Ad_hominem#Common_misconceptions
Admin
Admin
Well that's clearly not right. The proper way to represent gender is via normalized floating point (where 0.0f == wholly female, 1.0f == wholly male, 0.5f == perfectly hermaphrodite, and so on). "Unknown" (and/or Lady Gaga) is represented by NaN.
Admin
If it's ok for a string to be both true and false, then the solution to this WTF is obvious.
Problem solved.
Admin
I so want to be there when someone realizes you just implied male>female.
Admin
how great would it be to have some solid, real-world technologies like CICS (which probably has something to do with Cisco) and VSAM (Virtual Something Something Something... clearly a cutting-edge technology
Dude accepts a job, the description of which includes a list of technologies, and he doesn't research what the technologies are? He not only deserves spaghetti code, he deserves to be bitch-slapped with spaghetti noodles.
Admin
"F"illed "N"ull
.. it all depends on the context, now, does it?
Admin
Admin
I did something similar in C the other day. (It was for a cleaner way of accessing bit fields inside of the 32bit register of some sort of peripheral.)
The following code compiles:
#include <stdio.h> #include <stdlib.h>
// combining 8 bit elements // (plus 24bit placeholder) into an int static union { struct { unsigned int bit0 : 1; unsigned int bit1 : 1; unsigned int bit2 : 1; unsigned int bit3 : 1; unsigned int bit4 : 1; unsigned int bit5 : 1; unsigned int bit6 : 1; unsigned int bit7 : 1; // omitted 8 to 31 (excercise for reader :) unsigned int unused : 24; } ; unsigned int value; } bools; // Note: Asumtion unsigned int is indeed 32 bit.
int main (void) {
bools.value = 0; // clear all bits
// pattern '0xa5' bools.bit0 = 1; bools.bit2 = 1; bools.bit5 = 1; bools.bit7 = 1;
printf("hex: %02x\n",bools.value);
// pattern '0x5a' bools.value = bools.value ^ 0xff;
printf("hex: %02x\n",bools.value);
// pattern '0xc3' bools.bit0 = 1; bools.bit1 = 1; bools.bit2 = 0; bools.bit3 = 0; bools.bit4 = 0; bools.bit5 = 0; bools.bit6 = 1; bools.bit7 = 1;
printf("hex: %02x\n",bools.value);
// works the other way 'round bools.value = 0x7e; printf("binary: %1d%1d%1d%1d%1d%1d%1d%1d\n", bools.bit7,bools.bit6,bools.bit5,bools.bit4, bools.bit3,bools.bit2,bools.bit1,bools.bit0);
return 0; }
gcc bool.c ./a.out
hex: a5 hex: 5a hex: c3 binary: 01111110
You should be able to do this (haven't tried it yet):
if (bools.bit0 && !bools.bit1) { .... }
Admin
And of cause I forgot the mandatory:
static union { struct { unsigned int is_true : 1; unsigned int is_false : 1; unsigned int file_not_found : 1; unsigned int frist : 1; unsigned int brillant : 1; } ; unsigned int value; } paula;
... which only works on an embedded system without a filesystem.
SCNR :)
Admin
If it prevented idiots from trying to use floating point numbers for financial calculations then I say it was a good thing.
Admin
Admin
Anyway, who needs Booleans? If Oracle doesn't need them, nobody does.
[goes back to working on PL/SQL project and banging head against wall]
Admin
Exposure to oxygen alone does not cause wine to turn to vinegar. It will cause oxidation only.
To get vinegar you need to have an additional micro organism - acetobacter (mother of vinegar)
fruit juice + yeast = wine wine + acetobacter = vinegar
Admin
Admin
Admin
If the code was written in the 60s and was running on an AS/400 they had at least done a hardware upgrade at some point, which is more than a lot of places manage.
Presumably sometime before the 2000 when IBM started trying to give it modern sounding name.
Admin
Looking at all of this reminds me of one of the boolean logical bit types in the VHDL language (which although defined by the US DoD gets used in Europe while the US uses Verilog ..) :
quote Wikipedia ...
The primary data type std_ulogic (standard unresolved logic) consists of nine character literals in the following order[1]:
'U' - uninitialized
'X' - strong drive, unknown logic value
'0' - strong drive, logic zero
'1' - strong drive, logic one
'Z' - high impedance
'W' - weak drive, unknown logic value
'L' - weak drive, logic zero
'H' - weak drive, logic one
'-' - don't care
And then there are resolution functions which says what the result will be when a weak 'logic zero' meets a strong 'logic zero'
Admin
CMP var, 'F' JNZ IsTrue
AND var,0x4 JNZ IsTrue
will both take a couple of cycles in an intel processor.
Admin
CAPTCHA: abbas - as if one of them wouldn't be enoug to let your ears bleed!
Admin
Didn't the AS/400 come with DB2/400 RDBMS?
Admin
Please stop knocking AS/400s and mainframe ... you know all that cool suff you have now: machine virtualisation, multitasking, instruction set virtualisaton etc etc etc...OS/360 did it all (and in 16K!)
Give me an AS/400 any day!
Zog -- still mourning the good old days of Sun ... the SparcStation 1 ... what a beast!
Admin
IMHO, printing output to the console should not be considered a feature of the "language", but instead, a responsibility of the "operating system". After all, assembly doesn't have any way to print to a console either... it's done through an interrupt to the OS.
A language isn't portable if it relies on the assumption that it is running on a particular type of machine, whether that is a PC or a remote control car (which shouldn't have a console for output, by the way). That's where the beauty of C comes from - it's portable assembly.