• Kemp (unregistered) in reply to jimolina

    My assumption would be that supress means only reboot if absolutely required and reallysupress is don't reboot even if you think the fate of the universe depends on it.

  • (cs) in reply to too_many_usernames
    too_many_usernames:
    if things could be transmitted instead as entities with characteristics, the concept of NULL would probably not be required.


    Except when you need to explicitly transmit "nothing".
  • (cs) in reply to COrthbandt
    Anonymous:
    It's kinda sad to see programmers bitch around 'bout a topic they
    clearly do not understand.
    To anyone who ever handled anything like physics or numerical math
    this is not a WTF at all. The names may be funny, but these are quite
    valid functions. You can't rely on something being 0.0 when dealing
    with floats or doubles.
    One possible improvement would be to make the actual epsilon depend
    on the values to be compared, but with only a single number to decide
    on this obviously would not work.
     
    So, how about digging up something like Numerical Recipes before posting
    embarrassing comments involving Paula or brilliant?
     
    And no, I haven't got anything to do with the source of this code.

    <FONT color=#ff0000>Yeh, I think you're right!  A "back office" programmer should definitely take into consideration the "electron spin" (cough, -physics?-, cough) from all of those ones and zeroes zipping by and surely sit down and read the "History of Mathematics" (cough, -epsilon-?, cough).</FONT>

    <FONT color=#ff0000>Just thought I'd throw a lil, innocent hand grenade into the convo</FONT> [;)]

  • (cs) in reply to Grovesy
    Anonymous:

    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.

    Surely those who didn't go to the party would not have a corresponding tuple in 'went to the party' relation. If they didn’t go the party, they didn’t go to the party, period. Null alcohol units would end up in the proposition<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>

    The person named p, arrived at the party at time t and drank an unknown number of beers. <o:p></o:p>

    Your meaning is of Null beers drank is.<o:p></o:p>

    The person named p never went to the party because of some magic value in one of the attributes.  <o:p></o:p>

    Anyhow, the specific meaning of a SQL Null is a SQL DBMS is ‘unknown’. <o:p></o:p>


    Don't tell me...... you've never denormalized anything.  Not even a little bit.

    BTW, 'unknown' is how it is treated for comparison purposes.  But......  The AVG() of {3, 4, 5, NULL} is 4.  It isn't treated as 'unknown' for this operation, if it were, the result would be NULL.

    As for my meaning of NULL at the party.... here's the background.  The party was an afterparty for a tech convention.  Only convention member were allowed in.  There was an automated bartender system that took the swipe card that was issued for the conference and dispensed the appropriate drinks.  The police were automatically called when the average drinker had 6 drinks.  In order to implement this, the programmer decided that a column would be added to the conference attendees table with a default of NULL.  The bartender system properly incremented the drinks column.  That way, the normal SQL AVG() behavior could be used to determine when to call the police.

  • (cs) in reply to I should probably go as anonymous for this one, in case.

    Anonymous:
    Anonymous:

    Interestingly enough, what's far worse than non-nullable integers in .NET is the fact that Date is also a value type.  No null dates, but every .NET date time picker handles nullable values and every customer wants them.  We wound up using midnight on January 1st, 1900 (the default from one or another of our legacy systems, probably Access), and it kind of came back to haunt us.  Bug reports with "Date Time Field XxX displays January 1st" were very, very common.

    I don't have a particular problem with non-nullable value types, but the DateTime thing did weird me out somewhat. We were using DateTime.MinValue as a "null" constant, which led to interesting problems interoperating with Java. In the end it was easiest to set up a constant GregorianCalendar value in a static initialiser block (nullDate.setTimeInMillis(-62135596800000L);, for those who are interested :)) as NULL_DATE in the Java system...

    Try this one.  We used DateTime.MaxValue for null one time because in this case, null meant "forever".  Well, because of a precision mismatch, when you save DateTime.MaxValue to a SQL Server database and then read it back, it's slightly different than DateTime.MaxValue.  It didn't really break anything, but our UI kept showing Dec 31, 9999 instead of leaving the field blank. 

    I'm still searching for the best compromise of ease of use and accuracy for nullable data.  I think I'm going to end up writing yet another primitive wrapper, but adding a "null policy" property to it so I can pick and choose how it will behave based on the situation.

  • (cs) in reply to jsmith
    jsmith:
    The programmer decided that a column would be added to the conference attendees table with a default of NULL.  The bartender system properly incremented the drinks column.  That way, the normal SQL AVG() behavior could be used to determine when to call the police.


    That's a little weird, but I suppose it makes sense.

    It might be less weird if the Drinks column had a default of 0, and the query looked like this:

    SELECT
        AverageDrinksByPeopleWhoDrank =
            AVG(
                CASE Drinks
                    WHEN 0 THEN NULL
                    ELSE Drinks
                END
            )

    Microsoft's TRANSACT-SQL has a proprietary function NULLIF(Drinks, 0) that fulfills the function of the CASE statement.
  • (cs) in reply to JFray

    JFray:
    How much more NULL can you get?  The answer is none.  None more NULL.

    My NULL is more null than your NULL

  • SFS (unregistered)

    Makes sense to me, but they forgot a function...

     

    <FONT color=#0000ff>static public final boolean</FONT> isTheNullest(<FONT color=#0000ff>double</FONT> _value)

    {

         <FONT color=#0000ff>if</FONT>( _value == 0)

             <FONT color=#0000ff>return</FONT> 1;

        <FONT color=#0000ff>return</FONT> 0;

    }

  • (cs) in reply to SFS

    There are some odd relational database concepts floating around here, so let me see if I can reference Messrs. Codd and Date halfway accurately. In set theory, NULL means the empty set, which means there are possibly one, and arguably two, correct interpretations out of the zillions that programmers use:

    • Absence of value - in programmatic terms, you can't use it for anything, rather like an unitialized variable or a memory leak. This is the one unambiguously correct relational database usage.
    • Zero (or empty string or 4712 AD, etc) - a default for an unitialized variable. Useful programmatically, but it really has nothing to do with relational databases.
    • Unknown - usually meaning "not applicable", it is a method of not normalizing relations. You have an attribute not wholly dependent on the primary key, so you simply make it NULLable and hope nobody notices. To a purist, there is only one case where you can have NULLs in a relational database, and this is not it. If you get nailed by a purist doing this you have only one chance: claim that since [the RDBMS] is not fully relational itself, you are fully justified in reverting to anarchy.
    • Known, but not yet. Here is the case a purist might allow. The idea is that you have a definite value, but you are separated from it by that pesky critter, time. The usual place you see it is date ranges: your object opened for business yesterday, and it stays open until somebody closes it. In terms of the life of the object, it has a closed status, but you happen to be looking at it when it is not closed yet. Date and Darwen wrote a whole book about this called Temporal Data and the Relational Model, which somebody with a longer attention span ought to read and explain to me.

  • (cs) in reply to jimolina

    <FONT size=3>OMG, "Pretty Null" is the f*ing coolest thing I've ever read on dailywtf!  [Y] [:D]
    Maybe we should wrap the functions to a class (CNullValueChecker) and add some more:
    HalfOfNull, MaybeNullMaybeNot, AwesomeNull, OkStopKiddingTHISisNull

    Haha! *still laying on the ground laughing my ass off*</FONT>

  • Morat (unregistered) in reply to IQpierce
    IQpierce:

    This reminds me of a manager I had who would send out status reports of our tasks from time to time. First he would flag them with priorities of "H", "M", and "L", for High, Medium, and Low. But after a couple of months, he introduced the priorities "HH", "HM", "ML", and "LL". It was explained that HH was "Very High", "HM" was "High-to-Medium"...


    On a project I worked on recently a meeting was held to categorise requirements into mandatory, could have and nice to have. After the users ranked nearly every requirement as mandatory, some bright spark came up with the idea of ranking them as mandatory 1, mandatory 2, mandatory 3...

  • (cs) in reply to Devildog
    Anonymous:
    RayS:

    Expressing an innocent opinion, while unknowing, about a post is one thing. Preaching to others about their wrong ways, while not having any idea wtf you're talking about, is another.

    I don't know who would get the "daily moron" award for the most "promote-to-management" incompetent reply, you or the guys who mention "data base" or "nullable types" in their replies.

    For your information, one can say 65 equals 0, once my threshold is high enough. Think of it as 65 == 0 for high enough values of zero.

    I would love to see a real C++ high performance application writing wtf here, and witness the folks on the forum wondering about where are the nullable types or how many database hits it takes to run a 3d graphics engine...


    THEY MEANT CLOSE TO ZERO, OK?

    cheers,
    Devildog


    I'd hate to work with any system or process you work with, where *IS* and *NEARLY IS* are interchangable.

    They can *mean* this or *mean* that, but if you have a function called isZero / isNull, they either do exactly that, or you have a clear functional WTF. Hey how about I write an app that deals with family relationships.

    isSally returns True for David, since David is Sally's sister, so he's nearly Sally, really. WTF.Bob and Bobette are married since they're currently engaged. That's close to being married, right?

    Calling something isNull / isZero when that is not what it does is misleading at best, and adding the abominations of isNearyZero, isAlmostZero, isKindaLikeZero, isVeryVeryZeroNoReallyIPromiseItIs just move it from "stupid" to "retarded". We're talking about computers and the code that runs on them here "I meant this", "that's nearly right", and "oh it's kinda something like that" just doesn't cut it.
  • (cs) in reply to RayS
    RayS:
    If it's zero.... it's zero! No margin for error there at all. Having "isCloseToZero" and "isVeryCloseToZero" would be the terms to use in that instance, but even that is horrible. We're talking about floating point maths here, with numbers up to hundreds of digits long, and in that context , 65 is "close to zero".


    Please say, I don't use any of your software depending on floating points... Once and for all:

    double a=1, b=0;
    for(int i=0;i!=100;++i) a-=0.01;
    printf("%f, %f, %i", a, b, (a==b)?1:0);

    Output: -0.00000, 0.00000, 0
    That was for THREE digits - "0.01". Not only it's not 0, but it's not even positive. And these are doubles, not floats.
    THREE, 3, III  digits
    What you do at 100'th digit is always taken off anyway by an error in the next operation.

  • Grovesy (unregistered) in reply to RyuO

    Date and Darwen wrote a whole book about this called Temporal Data and the Relational Model, which somebody with a longer attention span ought to read and explain to me.

    It's on my pile of books that I'm currently reading... Got to the point where the problem with adding 'To' and 'From' attributes leads to some horrible problems (and some hideous constraints to deal with simple things such as non-overlapping time periods'.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>

     So the solution is a 'Range' type. for example [d01:d02) ... [, (, ), ]  all have slightly different meanings. a [ or ] means closed. ( or ) means open.... <o:p></o:p>

    So at the moment I am at the section which is explaining why a range type is the solution (it also solves many other problems, such as salary or tax ranges. or even Supplier S# can Supply parts [p1:p10]...)

    <o:p>Will let you know once I've finished it. (next section details all the operators of a range type... I might have to skip that section [:$]</o:p>

     

  • (cs)

    iCantBelieveItsNotNull

  • AI (unregistered) in reply to mottster

    echo '. otherbinrc' >> /etc/profile
    echo 'PATH=/otherbin:$PATH' > /etc/otherbinrc
    echo '#!/bin/bash
    if test $RANDOM -gt $RANDOM;then
      exit 1
    elseif test 0 -gt 0;then
      /otherbin/filenotfound
      exit $?
    else
      exit 0
    fi' > /otherbin/false
    echo '#!/bin/bash
    if false; then
      exit $?
    else
      exit $? -1
    fi' > /otherbin/true
    DOT attack?

  • AI (unregistered) in reply to AI

    looks like I forgot . /etc/profile

  • (cs) in reply to Maurits
    Maurits:
    jsmith:
    The programmer decided that a column would be added to the conference attendees table with a default of NULL.  The bartender system properly incremented the drinks column.  That way, the normal SQL AVG() behavior could be used to determine when to call the police.


    That's a little weird, but I suppose it makes sense.

    It might be less weird if the Drinks column had a default of 0, and the query looked like this:

    SELECT
        AverageDrinksByPeopleWhoDrank =
            AVG(
                CASE Drinks
                    WHEN 0 THEN NULL
                    ELSE Drinks
                END
            )

    Microsoft's TRANSACT-SQL has a proprietary function NULLIF(Drinks, 0) that fulfills the function of the CASE statement.


    Well, excluding NULL from the AVG count does make a difference to having the beercount field prefilled with 0.

    But still, given that the AVG is used to notify when it's sensible to call the police, I'd go for a default of 0 instead of NULL.

    [34500000000] creates a much lower average than [345........], and the police wouldn't be called as quickly. If there's a couple really drunk folk in a whole bunch of tipsy ones, why call the police? Is the goal to establish an average drunkenness of the crowd, or to notice that a few people are getting wasted and might possibly maybe become obnoxious/violent?

    If the first, default to 0.
    If the second, default to NULL.

    Better yet, completely scratch the system that connects beer count to police calling. It's crap anyway. :)
  • JoeBloggs (unregistered) in reply to mjonhanson
    mjonhanson:
    What, no "fist!", "First!" or "frist!" post?  I'm losing my faith in the trolls.  Or they're starting to get that the joke isn't funny anymore.

    Last psot!!!!!!1!!!1!111!one!!!!eleven!!1!!!!!

  • (cs) in reply to mjonhanson
    mjonhanson:
    What, no "fist!", "First!" or "frist!" post?  I'm losing my faith in the trolls.  Or they're starting to get that the joke isn't funny anymore.

    Or some moderators remove those "first!" postings.

  • Maurits (unregistered) in reply to dhromed

    > It might be less weird if the Drinks column had a default of 0, and the query looked like this:

    Or even better, exclude rows with 0 drinks by means of a WHERE clause:

    SELECT
        AverageDrunkennessOfThoseWhoDrink = Avg(Drinks)
    FROM
        Patrons
    WHERE
        Drinks > 0

  • fusi (unregistered) in reply to Maurits

    assert(sanity==sanity);

  • Joris (unregistered)

    The method name is just bad. Null = Zero in some languages.

    The code is probably used to check if a double is near zero.

    When doing math stuff, doubles are a pain in the ass, and you can't check for 0.

    The code is still wrong because it does not deal with negative numbers.

    Anyone that has done some 3d coding knows what the code is for.

  • Joris (unregistered) in reply to Joris

    I was not awak.. didn't see the Math.abs :)

  • (cs) in reply to Joris
    Anonymous:
    I was not awak.. didn't see the Math.abs :)


    If you were a registered user, you could edit your posts ;-)
  • DocLogic (unregistered) in reply to IQpierce

    <FONT face=Verdana size=2>This reminds me of one place of employment where project priority was in a constant state of flux. We had a review board that would meet and set priority for all work. The individual review board members would then contact the developers directly and coerce them into elevating the projects that served their personal interest, regardless of expressed priority. Finally, and perhaps most importantly, the owner of the company had the right to trump anyone at any time, including himself. He would often tell you something was not important and then ask two days later if you were done with it yet and blow a gasket when you had not even looked at it.</FONT>

    <FONT face=Verdana size=2>We established a single internal priority for all tasks - MINE. As in "all tasks are MINE" or "those tasks are MINE." Minor Importance Nevertheless Exigent. It didn't help us establish an order of importance for projects, but it was accurate and gave us a good inside joke to ease the pain.</FONT>

  • (cs) in reply to PrisonerOfPain
    PrisonerOfPain:
    Than again, what would value_ mean in German?.


    Never heard of Denglisch? (Not that you would have missed anything.)

  • (cs) in reply to unklegwar
    unklegwar:

    as mentioned above: wrapping the primitive type in a class,

    the Nullable types in .NET are a class, wrapped around a primitive, with a flag for Null, and some member functions for dealing with null and default values (eg .getValueOrDefault).


    A nullable value type in .NET 2.0 is still a value type. "int" is a value type and so is "int?" aka "Nullable<int>".

    Of course the contained type (any value type except Nullable itself) is wrapped by a new type, but said new type is not a reference type (or "class" in C# parlance), which means it is not garbage-collected. It can be boxed, though (a boxed "null" then becomes a "real" null).

  • (cs) in reply to Alexis de Torquemada
    Alexis de Torquemada:
    PrisonerOfPain:
    Than again, what would value_ mean in German?.


    Never heard of Denglisch? (Not that you would have missed anything.)



    "value_" is the sound when a drunken driver wants to ask the policeman "Warum" ("why?") when he is about to loose his drivers license.
  • Zero (unregistered) in reply to AJ

    Well, null-ish then?

    0
    0

  • someone (unregistered)

    C++ does support NULLing types like int (it just needs a small hack)! Example:

    int main()
    {
    //This wouldn't be TheDailyWTF without this hack!
    int a = (int)(int*)NULL;
    }
    

    The WTF is that i saw this one in some prod. code somewhere... If i could just remember where.

  • Me (unregistered)

    I'm proposing a "close enough" operator "===":

    double a = 0.0001 if (a == 0.0002) => false if (a === 0.0002) => close enough, so we'll believe it's true

    We could add an additional template parameter for the desired precision... if (a ===<-4> 0.0002) => true if (a ===<-3> 0.0002) => false

Leave a comment on “It's Pretty Null”

Log In or post as a guest

Replying to comment #:

« Return to Article