• (cs)

    Hey, he's using nearly only primitive types, must be hella efficient musn't it?

    And let me guess, all these underscore-prefixed variables are... like... constants? or are they merely private instance variables?

  • (cs)

    [:|]

    OMG... Convert has a ToDateTime method that takes a float... good grief

  • (cs) in reply to redtetrahedron

    This is a joke, right? No one would actually convert it that many times? Right?

  • (cs)

    holy efficient............so like.....say 20 instances of the object call their GetDisplayValue function...............now we have 100 variables, weeeeeeeeeeeeeee!!!!  That's what this thing must be......it's a variable-making machine!

  • (cs)

    What I can't figure out is why he's converting to decimal, then to double at all.

    I can sort of understand the (whatever)-long-datetime If for some reason he wanted to truncate the time part of the datetime. But to get a locale-specific string representation of just the date requires only a single character in the format string. "d" or "D" depending on whether you want short or long format.

  • (cs)

    Wow...if THAT MANY problems can be crammed into that ammount of code, imagine what a gem the rest of the application must be...ok maybe we shouldn't.

  • (cs) in reply to Mike R

    Uh. This guy must know something mere mortals dont about the space time continum. For sure.
    Or he might have been drunk/stoned while coding.

  • (cs)

    With that many crazy-ass turns in that short of a space, I'd say he's running from the cops.

    Or developed a proprietary obfuscation scheme.

  • (cs) in reply to redtetrahedron
    redtetrahedron:
    OMG... Convert has a ToDateTime method that takes a float...

    No...  See, that's the method they expect us to use!

  • (cs)

    Hey um... where did the Preview button go?
    Send out the search parties, it's missing!

  • (cs) in reply to Mike R
    Mike R:
    What I can't figure out is why he's converting to decimal, then to double at all.

    I can sort of understand the (whatever)-long-datetime If for some reason he wanted to truncate the time part of the datetime. But to get a locale-specific string representation of just the date requires only a single character in the format string. "d" or "D" depending on whether you want short or long format.



    Would it be a WTF if the rationale were readily discernable?

  • (cs) in reply to John Bigboote

    I think I figured out the reason. He's using the rube goldberg pattern for getting a string representation of a date!

  • (cs) in reply to loneprogrammer
    loneprogrammer:
    Hey um... where did the Preview button go?
    Send out the search parties, it's missing!

    Since it was completely buggy and more than likely wouldn't've been fixed, it was merely removed.

    If you want some kind of preview, write in HTML and switch to design view .

  • (cs)

    The real question is: Why is a date being stored somewhere as a float? If the date was being stored properly, it would not have needed all those conversions in the first place.

  • (cs) in reply to masklinn
    masklinn:
    loneprogrammer:
    Hey um... where did the Preview button go?
    Send out the search parties, it's missing!

    Since it was completely buggy and more than likely wouldn't've been fixed, it was merely removed.

    If you want some kind of preview, write in HTML and switch to design view .

  • (cs) in reply to joost
    Ok. Yes. That was the quote. Now for my reply, which I had put beneath the quotation, but which got completely undisplayed.

    "LT"!--
    "LT"input type="submit" name="_ctl0:PostForm:PreviewButton" value=" Preview > " onclick="if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); " language="javascript" id="_ctl0_PostForm_PreviewButton" Name="PreviewButton" ButtonType="PreviewMessage" /"GT"
    --"GT"

    You can always write a GreaseMonkey script if you want the Preview button back.

    (I replace "GT" and "LT" with their obvious meanings, I didn't want to upset Telligent's ungodly creation.)


  • (cs) in reply to Ulvhamne

    Ulvhamne:
    Uh. This guy must know something mere mortals dont about the space time continum. For sure.
    Or he might have been drunk/stoned while coding.

    <FONT face="Courier New" size=2>don't knock it 'til you've tried it.  lest steve, king of miami be on the prowl:</FONT>

    <FONT face="Courier New" size=2>http://www.moralminority.org/thread.phtml?tid=290</FONT>

  • Wyatt Earp (unregistered) in reply to joost

    this is c#.  Nevermind the fact he could off by hours.  the constructor for a datetime takes the number of 100-nanosecond intervals since 12:00 AM Jan 1, 0001, which he is retriving from a 32-bit floating point.

  • Rob (unregistered) in reply to Volmarias

    No way!

    Gotta be made up.

  • Rob (unregistered) in reply to javacrypto

    javacrypto:
    The real question is: Why is a date being stored somewhere as a float?


    Microsecond precision?  Like PHP's microtime(), which returns a float UNIX timetamp with microseconds in the decimal.  That's the only thing I can think of.  Though this snippet doesn't exactly look like it came from a precision environment.

  • (cs)

    I see two possible explanations:
    a) someone was making fun (most likely)
    b) for some extremely strange reasons, they wanted to display date that can be safely converted back to any numerical type without further losing precision (because this function already lost anything that is to lose)

  • (cs) in reply to Rob
    Anonymous:
    javacrypto:
    The real question is: Why is a date being stored somewhere as a float?


    Microsecond precision?  Like PHP's microtime(), which returns a float UNIX timetamp with microseconds in the decimal.  That's the only thing I can think of.  Though this snippet doesn't exactly look like it came from a precision environment.

    Any sane modern language has an arbitrary length integer type, or at least a 64bits one. C#'s "long" is an alias for System.Int64, a 64bits integer.

    Since C#'s DateTime does a "tick count" since January 1st, 0001 and a tick is 100 nanoseconds, it can run up to year 58454 (and 3 months). I guess it's pretty much enough. And no, it's not a UNIX timestamp.

  • me (unregistered) in reply to masklinn

    According to MSDN c# maxdate value is

    MaxValue: The value of this constant is equivalent to 23:59:59.9999999, December 31, 9999, exactly one 100-nanosecond tick before 00:00:00, January 1, 10000.

  • (cs) in reply to me
    Anonymous:

    According to MSDN c# maxdate value is

    MaxValue: The value of this constant is equivalent to 23:59:59.9999999, December 31, 9999, exactly one 100-nanosecond tick before 00:00:00, January 1, 10000.

    Well, yeah, that's what's written in the documentation, but the datas you build your DateTime object from could allow them to run up to year 50000, that's all I meant.

  • (cs)

    Has to be fake, no one is that stupid... I hope.

  • -L (unregistered) in reply to javacrypto
    javacrypto:
    The real question is: Why is a date being stored somewhere as a float? If the date was being stored properly, it would not have needed all those conversions in the first place.

    Have you ever heard of the Y2K problem? This guy obviously has, and has taken the precautions (after all, in Java floats go up to ~2**127, whereas ints only go to 2**31).

    Oh, wait...
  • Arachnid (unregistered) in reply to masklinn
    ItsAllGeekToMe:
    holy efficient............so like.....say 20 instances of the object call their GetDisplayValue function...............now we have 100 variables, weeeeeeeeeeeeeee!!!!  That's what this thing must be......it's a variable-making machine!


    Um, no. With a single thread of execution, there's only ever one call to the function at any one time.
    Oh, and 20*4 is 80, not 100.

    masklinn:
    Any sane modern language has an arbitrary length integer type, or at least a 64bits one. C#'s "long" is an alias for System.Int64, a 64bits integer.


    Name a single 'sane modern language' that has an arbitrary length integer type. Libraries for dealing with them don't count.
  • (cs) in reply to Arachnid
    Anonymous:

    Name a single 'sane modern language' that has an arbitrary length integer type. Libraries for dealing with them don't count.


    Python
  • Jared (unregistered)

    If you're like me, when you see something like this you're going to start asking "what if the WTFers are wrong? what if this method is just poorly documented and is actually the best way of doing something special?" So I did some reading on MSDN and I can assure you, this is a legit WTF:

    First, recall the C# aliases for .NET type names: float :: System.Single, decimal :: System.Decimal, long :: System.Int64

    • Convert.ToDecimal(Single) is a widening conversion, so dVal2 has the same precision as fVal.
    • Convert.ToDouble(Decimal) will throw an exception if it narrows, but Single < Double so we know this won't happen.
    • The explicit type conversion Double -> Int64 is narrowing with exactly the same semantics as Single -> Int64.
    So I can say with some confidence that this method has identical semantics to:
    public string GetDisplayValue(float fVal)
    {
    long dVal = (long) fVal;
    DateTime DAT = new DateTime(dVal);
    return DAT.ToString(_dateFormat, _dfpi);
    }

    There is a miniscule possibility that the rounding done by conversion from Single to Int64 is meaningful, but I have another theory: this method was written by a programmer who had been given the specification and was pissed off that date-times were being stored in floats.

  • (cs)

    I don't recall giving you guys permission to print my copyright code for date converting... 

  • (cs) in reply to Arachnid
    Anonymous:

    Name a single 'sane modern language' that has an arbitrary length integer type. Libraries for dealing with them don't count.


    java.lang.BigInteger

    And don't tell me it is a library.  It is a class and in java classes define TYPES.
  • (cs)

    There have been occasions where to replicate expected behavior from older systems (aka bugs with seniority), I've had to write date conversions like this.

    I've always had the grace to write an "apology comment" for them in the routine, though, to try to prevent the inevitable emotional damage to future generations...

  • (cs) in reply to wakeskate

    wakeskate:
    I don't recall giving you guys permission to print my copyright code for date converting... 

    <FONT face="Courier New" size=2>you're the owner of this wtf?</FONT>

    <FONT face="Courier New" size=2>i think copyright law doesn't apply here, since copyrights are supposed to protect intellectual and creative assets.</FONT>

    <FONT face="Courier New" size=2>now, if you had written it as a joke...</FONT>

  • Jeremiah (unregistered) in reply to Arachnid
    Name a single 'sane modern language' that has an arbitrary length integer type. Libraries for dealing with them don't count.
    Ruby Lisp
  • Arachnid (unregistered) in reply to ammoQ
    ammoQ:
    Anonymous:

    Name a single 'sane modern language' that has an arbitrary length integer type. Libraries for dealing with them don't count.


    Python


    As far as I can establish, Python doesn't have built-in arbitrary length integer math, it just has libraries like every other language. Anyway, my point was that languages generally don't include an arbitrary length type as a native type.

    In any case, using one for a datetime would be foolish.
  • Arachnid (unregistered) in reply to whoisfred
    whoisfred:
    Anonymous:

    Name a single 'sane modern language' that has an arbitrary length integer type. Libraries for dealing with them don't count.


    java.lang.BigInteger

    And don't tell me it is a library.  It is a class and in java classes define TYPES.


    No, classes are classes. The native types in Java are integer, boolean, etc. Just because it's part of the standard library doesn't mean it's a native type.
  • wtfer (unregistered) in reply to masklinn
    masklinn:
    loneprogrammer:
    Hey um... where did the Preview button go?
    Send out the search parties, it's missing!

    Since it was completely buggy and more than likely wouldn't've been fixed, it was merely removed.

    If you want some kind of preview, write in HTML and switch to design view .



    Why don't we start peeking at this forum's software code? Must have a dozen WTFs. Why look elsewhere..
  • Arachnid (unregistered) in reply to Arachnid
    Anonymous:
    ammoQ:
    Anonymous:

    Name a single 'sane modern language' that has an arbitrary length integer type. Libraries for dealing with them don't count.


    Python


    As far as I can establish, Python doesn't have built-in arbitrary length integer math, it just has libraries like every other language. Anyway, my point was that languages generally don't include an arbitrary length type as a native type.

    In any case, using one for a datetime would be foolish.


    Oops, you're right, Python does have built-in arbitary length integer math. Leaves me wondering why it also has libraries for the same purpose.

    Anyway, it's still not 'any sane modern language'.
  • (cs) in reply to Arachnid
    Anonymous:

    Anyway, it's still not 'any sane modern language'.


    Not sane? Not modern? Not "any"?


  • (cs) in reply to Arachnid
    Anonymous:
    whoisfred:
    Anonymous:

    Name a single 'sane modern language' that has an arbitrary length integer type. Libraries for dealing with them don't count.


    java.lang.BigInteger

    And don't tell me it is a library.  It is a class and in java classes define TYPES.


    No, classes are classes. The native types in Java are integer, boolean, etc. Just because it's part of the standard library doesn't mean it's a native type.


    You originally asked for an arbitrary length integer TYPE (without "native"), and a Java class most certainly is a type in Java terminology. And why should libraries that are part of the runtime distribution "not count"? This is a pointless debate based on uncertain definition of terms and arbitrary distinctions.
  • (cs) in reply to ammoQ
    ammoQ:
    Anonymous:

    Name a single 'sane modern language' that has an arbitrary length integer type. Libraries for dealing with them don't count.


    Python

    Dammit, I wanted to say it

    Well, I'll add ruby to the list then, which behaves the same as Python: stores regular integers in the integer built-in type, and automatically switches to the built-in arbitrary int (long for Python and Bignum for Ruby) when it spills out of the base int's range

    Anonymous:
    ammoQ:
    Anonymous:

    Name a single 'sane modern language' that has an arbitrary length integer type. Libraries for dealing with them don't count.


    Python


    As far as I can establish, Python doesn't have built-in arbitrary length integer math, it just has libraries like every other language. Anyway, my point was that languages generally don't include an arbitrary length type as a native type.

    In any case, using one for a datetime would be foolish.

    You, sir, can't establish shit.

    From Python's Numeric Types page:

    There are four distinct numeric types: plain integers, long integers, floating point numbers, and complex numbers. In addition, Booleans are a subtype of plain integers. Plain integers (also just called integers) are implemented using long in C, which gives them at least 32 bits of precision. Long integers have unlimited precision.

    Ruby's bignum is built in and behaves the same way, Lisp has had arbitrary length for years, and I specified "arbitrary or at least 64bits long"

    Oh, and Java types are still types even though they're not primitive types. From the Java tutorial itself, Java has two categories of data types, primitives (which you define as "native") and references which are still types. Integer, String or Bignum may not be primitive types, but they're still types (or do you consider that Java doesn't have any String type?)

  • (cs) in reply to brazzy
    brazzy:

    You originally asked for an arbitrary length integer TYPE (without "native"), and a Java class most certainly is a type in Java terminology. And why should libraries that are part of the runtime distribution "not count"? This is a pointless debate based on uncertain definition of terms and arbitrary distinctions.


    If bigints are a native part of the language, you have literals and operators to work on them.
    For example, the following ficitve Java snipplet would work:

    ...
      public bigint myBIGincrement(bigint x) {
        return x+1000000000000000L;
      }
    ...
    

    Without that, it's less readable:

    ...
      public BigInteger myBIGincrement(BigInteger x) {
        return x.add(new BigInteger("1000000000000000"));
      }
    ...
    

    Of course, languages with operator overloading (C++, C#) would allow you to make the operators work as expected, but that's still not the same; literals would still be missing and of course bigints should be value types, not reference types, to be consistent with other numerical types. Other things still missing in C# would be the ability to use BigInts for switch statements, array indexing, casting etc.

  • Arachnid (unregistered)

    Fine, I'll rephrase: Most languages don't have arbitrary length integer support built in. Most programs don't need it, and it's certainly not needed (or wise) for storage of a timestamp.

    Java having a BigInt type is no different to any other language having a library for manipulating large integers. It happens to be in the standard library, but it's not part of the language. I asked for languages that had built in large integer types, not libraries.

  • (cs) in reply to Arachnid

    Anonymous:
    Fine, I'll rephrase: Most languages don't have arbitrary length integer support built in. Most programs don't need it, and it's certainly not needed (or wise) for storage of a timestamp.

    Java having a BigInt type is no different to any other language having a library for manipulating large integers. It happens to be in the standard library, but it's not part of the _language_. I asked for languages that had built in large integer types, not libraries.

    woo hoo! Another language war thread! Only took about 20 odd posts this time and everybody has already forgotten about the WTF.

  • (cs) in reply to Arachnid
    Anonymous:
    Name a single 'sane modern language' that has an arbitrary length integer type. Libraries for dealing with them don't count.


    Lisp, Rexx, Haskell
    http://en.wikipedia.org/wiki/Integer_%28computer_science%29
  • (cs) in reply to masklinn
    masklinn:
    ammoQ:

    Python

    Dammit, I wanted to say it


    First post ;-)


    Oh, and Java types are still types even though they're not primitive types. From the Java tutorial itself, Java has two categories of data types, primitives (which you define as "native") and references which are still types. Integer, String or Bignum may not be primitive types, but they're still types (or do you consider that Java doesn't have any String type?)

    While strings are not primitve types in Java, I still consider them native to the language; there are strings literals, string operators, the toString() method in the Object class; for that reasons, it's obvious that they are something special you could (unlike the BigInteger class) not build on your own within Java.

  • Tony Morris (unregistered) in reply to ammoQ

    It is one of the many unfortunate flaws of Java that the J2SE API Specification and Java Language Specification are heavily bound in an ad hoc manner. One cannot talk about one without inadvertantly talking about the other, or at least, to do so makes little sense. The dependency pointed here is one of many. I know of one such language currently underway that takes advantage of the relative unbrokenness of the JVM Specification while completely rewriting the language and API specification "properly". In fact, I do this in my spare time however, while I'm at work, I implement the J2SE specification itself, which some might argue is competing against my employer, but that's another story.

    --
    Tony Morris

  • (cs)

    I find the effort and cleverness put into the blurb much more interesting than the code itself. The twisty maze of little casts, all alike isn't even bad in some inspired way that pushes the boundaries of badness.

  • (cs) in reply to redtetrahedron
    redtetrahedron:

    [:|]

    OMG... Convert has a ToDateTime method that takes a float... good grief



    You can thank microsoft excel for putting date and time into a float.   That is the first place I saw it, about 16 years ago.

  • (cs)

    I don't think i could come up with any responses for that funtion until I get to know what the values for "_dateFormat", & "_dfpi" are...

    Or do i?

    Anyways, I demand for the values for those two unknown (possible  properties[with bad naming convention] or a private member vars)!!!

Leave a comment on “It's a Float. It's a Long. It's SUPERDATE!”

Log In or post as a guest

Replying to comment #43103:

« Return to Article