| « Prev | Page 1 | Page 2 | Next » |
|
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
|
|
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! |
|
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. |
|
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
|
|
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
|
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
|
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
|
|
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
|
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 |
|
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
|
|
Re: It's a Float. It's a Long. It's SUPERDATE!
2005-09-07 14:37
•
by
joost
|
Ok. Yes. That was the quote. Now for my reply, which I had put beneath the quotation, but which got completely undisplayed. |
Re: It's a Float. It's a Long. It's SUPERDATE!
2005-09-07 14:44
•
by
emptyset
|
don't knock it 'til you've tried it. lest steve, king of miami be on the prowl: |
Re: It's a Float. It's a Long. It's SUPERDATE!
2005-09-07 14:47
•
by
Wyatt Earp
|
|
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
|
|
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
|
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. |
|
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
|
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
|
|
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
|
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. |
|
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
|
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
|
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.
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
|
Python |
|
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
So I can say with some confidence that this method has identical semantics to: public string GetDisplayValue(float fVal) There is a miniscule possibility that the rounding done by
|
|
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
|
java.lang.BigInteger And don't tell me it is a library. It is a class and in java classes define TYPES. |
|
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
|
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
|
Ruby Lisp |
Re: It's a Float. It's a Long. It's SUPERDATE!
2005-09-07 17:59
•
by
Arachnid
|
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
|
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
|
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
|
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
|
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
|
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
|
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
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
|
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:
Without that, it's less readable:
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. |
|
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
|
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
|
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
|
First post ;-)
While strings are not primitve types in Java, I still
|
Re: It's a Float. It's a Long. It's SUPERDATE!
2005-09-07 19:30
•
by
Tony Morris
|
|
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 |
|
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
|
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. |
|
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)!!! |
| « Prev | Page 1 | Page 2 | Next » |