Comment On It's a Float. It's a Long. It's SUPERDATE!

Err, wait ... no, scratch that. It's just a string. Sorry for the disappointment everyone. Dang, I really thought that Paladl had found the ever-so-elusive Superdate. But not this time ... just a string that was a DateTime that was a long that was a double (briefly) that was a Decimal that was a float ... [expand full text]
« PrevPage 1 | Page 2Next »

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 13:37 • by masklinn

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?

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 13:41 • by redtetrahedron

[:|]


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

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 13:43 • by Volmarias
43084 in reply to 43083
This is a joke, right? No one would actually convert it that many times? Right?

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 13:54 • by 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!

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 13:55 • by 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.

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 14:01 • by tw000
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.

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 14:02 • by Ulvhamne
43089 in reply to 43087
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.

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 14:04 • by John Bigboote
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.

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 14:13 • by loneprogrammer
43092 in reply to 43083
redtetrahedron:
OMG... Convert has a ToDateTime method that takes a float...


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



Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 14:14 • by loneprogrammer
Hey um... where did the Preview button go?

Send out the search parties, it's missing!



Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 14:16 • by Richard Nixon
43094 in reply to 43087
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?



Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 14:20 • by Mike R
43095 in reply to 43090
I think I figured out the reason. He's using the rube goldberg pattern for getting a string representation of a date!

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 14:20 • by masklinn
43096 in reply to 43093
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 .

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 14:29 • by 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.

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 14:34 • by joost
43099 in reply to 43096
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 .

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 14:37 • by joost
43100 in reply to 43099
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.)



Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 14:44 • by emptyset
43103 in reply to 43089

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.


don't knock it 'til you've tried it.  lest steve, king of miami be on the prowl:


http://www.moralminority.org/thread.phtml?tid=290

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 14:47 • by Wyatt Earp
43104 in reply to 43100

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.

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 14:55 • by Rob
43105 in reply to 43084
No way!



Gotta be made up.

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 15:05 • by Rob
43107 in reply to 43097
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.


Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 15:10 • by ammoQ
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)

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 15:13 • by masklinn
43109 in reply to 43107
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.

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 15:18 • by me
43110 in reply to 43109

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.

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 15:26 • by masklinn
43112 in reply to 43110
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.

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 16:02 • by whojoedaddy
Has to be fake, no one is that stupid... I hope.

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 16:04 • by -L
43116 in reply to 43097
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...

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 17:03 • by Arachnid
43122 in reply to 43109
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.

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 17:10 • by ammoQ
43124 in reply to 43122
Anonymous:


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




Python

Don't Question The WTF

2005-09-07 17:34 • by Jared
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.



Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 17:41 • by wakeskate
I don't recall giving you guys permission to print my copyright code for date converting... 

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 17:45 • by whoisfred
43131 in reply to 43122
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.

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 17:47 • by SwinePearls
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...



Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 17:50 • by emptyset
43133 in reply to 43130

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


you're the owner of this wtf?


i think copyright law doesn't apply here, since copyrights are supposed to protect intellectual and creative assets.


now, if you had written it as a joke...

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 17:52 • by Jeremiah
43134 in reply to 43122
Name a single 'sane modern language' that has an arbitrary length integer type. Libraries for dealing with them don't count.

Ruby
Lisp

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 17:59 • by Arachnid
43135 in reply to 43124
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.

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 18:01 • by Arachnid
43136 in reply to 43131
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.

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 18:03 • by wtfer
43137 in reply to 43096
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..

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 18:19 • by Arachnid
43138 in reply to 43135
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'.

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 18:35 • by ammoQ
43139 in reply to 43138
Anonymous:


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



Not sane? Not modern? Not "any"?




Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 18:38 • by brazzy
43140 in reply to 43136
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.

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 18:44 • by masklinn
43141 in reply to 43124
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?)

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 18:57 • by ammoQ
43142 in reply to 43140
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.

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 18:58 • by Arachnid
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.

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 19:01 • by Quinnum
43144 in reply to 43143

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.

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 19:03 • by Maurits
43145 in reply to 43122
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

Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 19:05 • by ammoQ
43146 in reply to 43141
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.


Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 19:30 • by Tony Morris
43147 in reply to 43146
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



Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 20:52 • by Omnifarious

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.


Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 21:22 • by triso
43155 in reply to 43083
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.



Re: It's a Float. It's a Long. It's SUPERDATE!

2005-09-07 21:30 • by dance2die
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)!!!
« PrevPage 1 | Page 2Next »

Add Comment