- 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 do not think there is anything philosophical about it. The languages, databases, progrmmers and designers who accept the concept of 'nullness' define it as NO VALUE. Seems to me zero is a value.
Codifiers of systems of logic are allowed to coin such definitions.
Without null, the following dialoge (it should be obvious how to transform this to code) is impossible:
----------------------------------
How many do you want?
I haven't said.
OK - I will give you the default.
----------------------------------
Isn't that very different from:
--------------------------------
how many do you want?
Zero.
OK - I will give you zero (or not give you any).
--------------------------------
?
I know that this explanation is somewhat pedantic, but logic, programming and system design can, at times, appear to be very subtle to the untrained eye.
There is, in fact, a real difference tween null and zero and many designs would be handicapped or bullied into defining a magic value if the concept was not implemented already. In fact, null is a magic value in that it cannot be confused with a real number and it can, if desired, trigger alternate processing.
I do have a serious matter to bring up - nobody has suggested the obvious, essential and mandatory isNullAndVoid declarations.
Admin
This reminds me so much of
"He's not completely dead,... "
"She turned me into a newt!!"
Admin
We. Thought. You. Was. A. Toooooad!
Admin
This sounds a lot like "Meet Spinal Tap"...
How much more NULL can you get? The answer is none. None more NULL.Admin
This sort of reminds me of something I was going to do as an April fool's prank. I started working on a next-generation version of "true" and "false" called TrueNG. The idea was rather than just simple binaries /bin/true and /bin/false, I would instead have a shared library that implemented true as a function, and then have language bindings for perl, tcl, etc., as well as the traditional binaries (that just link against libtrue).
Version 2.0 was going to have network capability, not unlike distributed.net, where people could calculate the value of truth and submit it. It never got off the ground because I couldn't work out an implementation that didn't leave it open for a denial-of-truth attack.
Admin
LMAO! Brilliant![:D]
Admin
I had to do a double-take there. Good one.
Admin
How do you know she is a witch?
Admin
isNotQuiteNullYet
Admin
I'm pretty sure the root of all evil is this too, too, post-ironic and oft-repeated remark about premature optimization. I vote we place it up there with "Fist," "Brillant," and all the other old saws we have hanging over the workbench.
Admin
"And... what else floats?"
"Churches!"
"Very Small Rocks"
"A Duck!"
"... so... if she... weighs as much as a Duck..."
PAULA!
Admin
The correct names for these functions would be IsNearlyZero, and IsVeryNearlyZero. But I would take the advise given earlier and define some thresholds to compare against.
jmho.
Admin
If it's an XOR...
Admin
Two wrongs don't make a right, but if you add up enough nulls you'll get a non-null! Multiply a null by a big enough number, and you've really got something to work with. Subtract a nullity from a small enough reality, and it disappears.
If you need a NULL value, and you're in a context that doesn't support it (e.g. you can't create an object wrapper), then I might suggest carrying a neighbouring bool that indicates nullity. Or find a comparable solution. "Cute" is for personal tools and home hacks, where you can control the inputs.
bool someNumber_nullFlag;
As bad as the code gets, at least it avoids tripping into (or out of) a black hole accidentally. I'd hate to be the poor co-op student called in to fix a problem caused by somebody being billed because they ordered a null quantity of an expensive item ... and "fixing" it by ensuring they only ordered a very null quantity, instead!
Admin
Did you mean:
öffentlich statisch boolesch istNull(doppelt _wert) {
gibZurück (Math.abs(_wert) < 0.0001);
}
Admin
And I was just reading about various magic numbers, including the one about
const bool FALSE_FLAG = (0xCE0 == 0xDEAF);
...what, an old joke? Well, give me a break, just heard it today...
Admin
This is a good example of full frontal nullity.
Admin
No, no, no, you need to re_use code,
static public final boolean isWitch(Person accused, <FONT color=#0000ff>Duck</FONT> trialDuck)
{
return isNull(accused.Weight - trialDuck.Weight);
}
Admin
It's quite simple. All nulls are equal, but some values of null are more null than others.
Admin
Doesn't C/C++ just make NULL = (void *)0?
Seems like a pretty good definition of NULL to me.
Admin
denial-of-truth attack- thats gold!
Admin
I'd say it quite clearly DOES mean exactly that. A stupid name for the function, granted, but not stupid enough to be interesting.
Truly stupid code should show fundamental misunderstandings rather than poor name choices. Something that can be fixed with a search-replace is not that noteworthy.
Admin
Doesn't schools teach the concept of NaN (Not A Number). I mean, even C and C++ support these!
Yes, Javascript supports it as well. Try this:
alert(typeof(NaN));
Not A Number is a NUMBER! Bbbbbuut, if it's not a number, how can it be a number, unless it's Not A Number but then how can it be a number, AAAAAAAAAAAAUUUUUUUUGGHHHHH!
Admin
So do you think "ACHTUNG, ZERHACKSTÜCKUNGSAPPARATUR! JAHAHA, WUNDERBAR! NEIN, VERBOTEN! MEIN LEBEN!" sounds... dull???
Then go ask your granddad (or some rtcw/et-player) what he thinks about those words. *evil grin*
P.S.: If you don't understand this humor, then YOU are dull! HARRR! ;)
Alternate P.S.: * Maybe he'll answer you and if it's raining all day and all night he might sound snobish and dull, while when it's hot like hell he'll probably sound like having a hot potato in his mouth. ;P
______
"Just remember: Here at Sunny Meadows, THERE IS NO I IN INSANITY!"
Admin
in C it is #define NULL ((void*) 0) as you said but in C++ it's #define NULL 0
Admin
You forgot
<FONT face="Courier New">isWithANameLikeMangledBabyDucksYouKnowItsGotToBeExtremelyNull()</FONT>
Admin
No, and they doesn't teach grammar either.
Admin
[8-)]
Admin
double isNuller(double a, double b) {
return (abs(a) < abs(b)) ? a : b;
}
--Rank
Admin
Beavis: Yeh, Yeh. Like I know Spanish, too! Yeh, "Pizza". Yeh, Yeh. "El, Nullo". Heh-heh
Admin
I owe you one. The first post (in this thread) to make me laugh out loud!
Admin
I do think this design could help in a number of not-simply-a-simple-null-value problems. I defently want to use this......
Admin
Now THAT is funny!
Admin
Is that for real? No
nullbull?After a bit of a-null-ysis I have null-ted that tis a most null-tible and null-farious use of code. To he person who found this, the null-ble thing to do would be to null-tify your supervisor. If you knull who wrote it, find someone more knull-igble to teach them better practices. There is null way this should be left standing as is. This kind of null-compoop thinking needs nullified. Either use a better solution (actual null-able values, or a flag.) or properly name the functions. To discourge them, you could award him a Null-Bell prize.You have the time it takes me to count from 0 to Null to get started (I'm trying to be generous... I could have said VeryNull).
....
What was that? Ok, I'll put down the stick.
....
Step away what?
...
Oh, the dead horse. Right OK.
Side note: Now that the value of Null if being replaced by functions, is Null still going to be backwards compatible, or will I need to write like this:
IF(Pointer == TheValueFormerlyKnownAsNull){ .... }
Admin
Admin
Nullth post!
Admin
"VERY NULL"! I actually laughed out loud at that. Good one.
Admin
Like most WTFs here, the real WTF is the people replying.
Null also means 'zero', which is obviously the intent of this code. As opposed to 'empty', which is the meaning we commonly consider 'null' to have.
For the idiots who state that he should have just tested for zero, you can't do that safely with double values, as it is incredibly rare that you will find two variables out of two different mathematical operations to have the EXACT same value. So 'A - B' will almost always have a remainder. Note that if you had ASKED why you couldn't do this, you would not be an idiot; asking would be a sign of wisdom, accepting that there are things which you do not yet know, and implying your desire to learn.
The WTF here is probably Mihhon, who incorrectly understood what the original author was doing. I would enjoy knowing if those method names are the original names; if so, so what? How many times have you, as a programmer, not been able to bother yourself to pause in a mad programming dash to think of the 'perfect name' for a method? IsNull? IsZero? IsTiny? IsReallyTiny?
My own function for this, which I used to use all the time, is called 'isZero' and takes two arguments, the value and the limit in sig figs. Still, I wouldn't consider a fellow programmer an idiot based on something like this; if I has only two particular zero cut-offs, I'd use two different methods as well; it is easier to refactor, if needed.
If this site took the view that 'bad code' should be made an example of, and CORRECTED, I would enjoy it. Instead the forums are full of idiots who think they impart wisdom with snappy comments such as 'HAHAH what an idiot! WTF++'.
I daresay this could be an interesting site, and it is SOooo close. But it falls flat, simply because it focuses on being insulting, rather than insightful. Hopefully others agree and the site improves. Until then, cheers,
Admin
In C++, I always use some sort of wrapper with a specially designed NULL created for the individual circumstance and avoid #define NULL 0 calls like the plauge.
Admin
Sorry. What I wouldn't give to be able to use that Edit button. I noticed my error right when I clicked the Post button.
Admin
The isNull() function in BrainF***. See how much simpler this makes things? Sadly, I couldn't figure out the ASCII for "very null".
>+++++++[<+++++++>>+++++++<-]>->,>[<]<.
Admin
Too true, unfortunately. It's obviously just for doing floating-point comparison, except he's hardcoded two different epsilon values with the two functions. Ok, so most people would have a more general solution (and probably come up with some better names for the functions), and probably wouldn't have used the word "null", which is a bit misleading, but hardly a wtf.
If you want to compare two floating point numbers for equiality, that is what you're supposed to do. First, subtract them from each other, then see if the resulting value is sufficiently small (by taking the absolute value and comparing it to some epsilon).
Admin
I've been following this site daily for a while now, probably six months. This is the first WTF that made milk come out of my nose.
Of course, the REAL WTF is that at nearly 5:30 PM it was milk and not a fine Kentucky Burbon.
Admin
You need HTM (Higher Than Medium), SHTM (Slightly Higher Than Medium), and ASHTM (A Smidgen Higher Than Medium)...
Admin
Actually...... Microsoft SQL Server doesn't have a placeholder value for NULL. It has a bitmap for NULLable columns and for every column that is NULL, the value is skipped in the chunk of row data. Therefore, a row is variable length and NULLs aren't stored as anything other than a NULL flag.
As for languages, most only support null for reference types. So, a null is a pointer that points to nowhere. You might think that's a value, but it takes less space than a non-null value. A null Date consists of only a two (or four) byte pointer. A non-null Date consists of a pointer and about 8 bytes of Date data(depending on language and platform).
NULLs do have a distinct meaning. Try adding 50 rows to database, set all of them to some value. Do an AVG() aggregate on the 50 values. Now set 10 of them to NULL. Do another AVG(). The NULLs will behave differently than any fixed value. This is very useful for cases like "How many servings of alcohol did the average party goer drink", where those who didn't go to the party have a NULL in the servings column. Those who went to the party, but didn't drink have a 0.
Admin
Clearly this is a fundamental concept which should be supported by the language. Binary logic just doesn't reflect modern cultural norms. We need
If ...
Then ...
Else ...
Maybe...
Admin
You'd have to declare a bitmap to hold the symbol that represents the new name of NULL. And comparing bitmaps is a pain, trust me.
<font size="2">public static bool areBitmapsTheSame(Bitmap b1, Bitmap b2) {
if (b1.Width == b2.Width && b1.Height == b2.Height)
// compare pixel values of the two bitmaps
}
public static bool areBitmapsTheVerySame(Bitmap b1, Bitmap b2)
{
return FILE_NOT_FOUND;
}
</font>
Admin
Who else stops reading as soon as someone starts a post like this? The real WTF is people not understanding sarcasm.
Admin
LOL! I wish I had this example for the chapter on designing encoding schemes in my books.
Admin
... this is obviously an implementation of "Tri-Null"