- 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
Ok, I have no idea there. You can perceive a reason, however ridiculous for stupid pieces of code to exist, but this one just doesn't makes any sense.
It's not a poor man's breakpoint, it's not merely a left-over unimplemented function, it just doesn't make sense. Perhaps the original author was drunk or tired, or it is the result of a copy/paste went wrong?
Perhaps it uses a weird compiler where the preprocessor allows to create a macro whose name is a whitespace?
Admin
I'd just like to point out that just because something is in common usage, doesn't mean it's not a serious WTF.
On the other hand, perhaps the real WTF is that there are 365.2425 days in a year.
Admin
Absolutely, and we here at the 'Mass. Organization of Radically Organizing Numbers and Space' are hard at work on the solution. Our current plan is to use rocket power to push the Earth into a slightly closer and faster orbit around the sun to bring us to an even 360 day year. After that we will begin work on that pesky PI number.
Admin
I believe that group has already taken up the matter of "that pesky number". ;-)
http://www.straightdope.com/classics/a3_341.html
Admin
FYI, a possible implementation in java of Double.isNaN(double d):
public boolean isNaN(double d)
{
return d != d;
}
Just to show that there are cases of testing to see if something is equal to itself.
Admin
So how would this apply to a bool-type variable?
Admin
I'm offended. We here at the 'Mass. Organization of Radically Organizing Numbers and Space' are working on REAL solutions!!!1one! Fixing PI will require small 'tweaks' to space-time to correct the problems of 2D and 3D geometry. Worry not, our capable scientists have the problem well under control.
Admin
Admin
... I got nothing.
I do notice that, if the whitespace does throw an error, the catch block creates an infinite recursion.
Admin
??? While there is no garuntee that any two NaN's in Java will be equal there is also no garuntee that any two NaN's will be different. However that only applies to two different NaN's, the code you posted will always return false.
Admin
My bad, I was testing Infinity rather than NaN. I retract my earlier statement. *walks away in shame*
Admin
Isn't it obvious? He is testing for filenotfound.
Admin
>perl -Wce"@{$gst}{keys %{$rec}} = values %{$rec};"
Name "main::gst" used only once: possible typo at -e line 1.
-e syntax OK
Please turn in your Monk-card -- hash slices've been around since before perl5. (Yes, I checked the no-curlies version too.)
Admin
Looks quite sensible to me. If b is NaN or b IS NULL, the assignment will be skipped. On the other hand, if b equals true, false, "brillant" or FileNotFound, it will be set to true.
WTF? I've used C, C++, Java and C# and this does not look the slightest bit "C stylee" (sic) to me. It looks more like Basic.
Of course, the real WTF is that Basic uses the same symbol for assignment and equality comparison.
Admin
Embedded <a href="http://en.wikipedia.org/wiki/Whitespace_%28programming_language%29">Whitespace</a>?
Rich
Admin
Re-read the "Slices" section of the perldata manpage.
Admin
PI is a mathematical construct that just happens to bear relation to geometry in Euclidian space. You can fiddle with space-time all you want and it won't change the value of PI.
You're going to need to dig in and change mathematics itself.
Rich
Admin
Actually no in VB = does both assignment and comparison based on context.
Comparison:
if b = 1 then ... end
Assignment:
b = 1
Lame, but that's Basic for you. :)
Admin
Sorry, I already beat you to correcting myself.
Equally as wtf is that other languages use the equality operator (=) for assignment then to test equality end up using things like "=="
Rich
Admin
Not necessary. Any mathematician knows that Pi = 3 for sufficiently small values of Pi and sufficiently large values of 3.
GWB: We ought to make the Pi higher.
AdT: No, dumbass, we ought to make it lower!
Admin
My sincerest apologies!
Yes, = is the mathematical equality operator, but it is also used to "fix" variables to certain values, which is quite similar to assignment in C (though more similar to assignment in functional programming languages). I think the decision for == and = was wrong because Pascal's = and := mirrors the similarities and dissimilarities to mathematical concepts more closely. But in any case that's better than using the same symbol for entirely different purposes depending on the type of expression it is used in.
In C, "a = b" is always interpreted in the same way no matter where you use it, and the same goes for "a == b" (assuming no outside operator with higher precedence interferes). In Basic, "a = b" can at one time mean one thing, and at another time mean another. I find this far more irritating than using == for comparison.
Admin
Ignoring the problem of this being based on a property of NaN which is not guarunted (as noted elsewhere), even if it were, it would have a problem, as the operator== (and therefore operator!=) would almost out of necessity have to call Double.isNaN, forcing infinite recursion
Admin
Just to clear a few things up here is a copy of the actual implemenation of Double.isNaN(double)
Admin
Actually, there is such a guarantee. From the Java Language Specification:
"The equality operator
==
returnsfalse
if either operand is NaN, and the inequality operator!=
returnstrue
if either operand is NaN."Regardless of the bit pattern, no NaN value ever equals another NaN value.
Admin
// TODO: do we even need these? I thought everyone spoke EN-US these days...
private static Language Russian = new Language("Russian"); // vodka-drinking mobsters
private static Language French = new Language("Freedom"); // cheese-eating surrender-monkeys
private static Language UKEnglish = new Language("English-UK"); // Hugh Grant
Admin
This is required by the Java language spec (the guy who first brought up NaN used a Java example, but this behaviour is also required by IEEE-754, which most progamming languages follow).
More likely it's implemented using the CPU instruction for floating-point comparison, which IIRC on most CPUs handles NaNs automatically (and on architectures where it doesn't, I expect the JIT would generate specialised code, or possibly a call to a built-in routine, but I highly doubt it would call a method written in Java).Admin
Reading the daily WTF regularly reminds me of the woeful lack of understanding of floating point issues and the conventions of the financial world among programmers. By that I don't mean just the coders whose work is displayed here for our enjoyment, but the readers and submitters, too. The domains and implementations of some things in code just result in unintuitive expressions sometimes, either to match the conventions of the users, or to get around limitations in computers.
It probably wouldn't bother me so much except for those times when teammates who didn't bother to learn the decided my code was obviously wrong and changed it to something "right". And the time the whole team ignored my advice (I was consulting) about not using Java float for money, and spent the better part of three months chasing bugs in calculations that were off by a penny, only to find that after multiple convoluted "fixes" to handle various special cases they still got the same bugs, or not, depending on the numbers input.
Admin
"It depends what the definition of 'is' is."
Admin
Admin
Actually, I've seen something similarly nonsense in a source that has been converted from assembly language to C++... the statement has been used to set certain CPU flags in the origional code, but somehow got it's way into the converted C++ one.
Captcha: paste. How I love copy and paste try-and-tested code everywhere!
Admin
falling from mars? or you never heard how some financial companies compute interest for days when a yearly interest rate was contracted? wake up please - this is not a wtf at all
Edit: I should have read the entire thread first I guess....
Admin
im fairly sure c style would look more like
if (b == b) {b = true;}
that snippet looks like basic
Admin
This calendar is not Babylonian. It caled 30/360 and is commonly used (at least in Europe) for banking and finance applications. In this calendar very month has 30 days and therefore a year has 360. This probably made calculating interest a whole lot easier when COBOL was not yet around.
Of course there is a slight advantage of 5-6 days where the bank doesn't have to pay interest to their suppliers. Using such a calendar nowadays is just ridiculous and only a means of ripping off customers. When dealing with debtors the effort of maintaining a 365/366 day calendar suddenly doesn't seem to be that much of an issue.
Admin
For I shall thank ye.
Admin
Admin
This looks perfectly fine to me. Apparently no one here ever heard of out of order execution.
Admin
In fact, this 360-days-a-year things isn't even technically; it's pretty old and pre-dates computers. It's rather normal here in europe (and to my knowledge, the financial world in general) and is used for a lot of things, not to mention a lot of (international) regulation which makes unilaterally switching to another calender system rather... adventurous.
Actually, most banks nowadays, DO compensate interest for the full number of 365/366 days a year, they mainly use 360 days internally. Obviously it doesn't make any difference whatsoever, because rates are based on 360 days as well. Get 3.60/360 % per day or 3.6525/365.25 % per day; it doesn't really make a difference.
Admin
I think you are right. A bank year has 360 days and I think it is used to pay interest.
They probably keep 5 days for them selves, the thieving b*stards
Admin
This is by far not clever enough. Take this:
b = (b == b ? true : false) ;
Remember, C is about doing things you can't do in Basic.
Admin
Or it could be a case where b sometimes is set to NULL and the test "NULL = NULL" yields NULL which is interpreted as False. The code above could then pass as a way of converting any non-NULL value to True, i.e. "b = not IsNull(b)".
Admin
I am not sure. It can be since he found lots of variable == true tests in the code, and only wanted to assure that if the logical value of it is true, then it is actually equals true...
Admin
Sorry, I wasn't careful enough, my last post is a mistake.
Admin
True, but C isn't consistent either. For example,
*foo(bar+37)
andfoo*(bar+37)
have wildly different semantics for*
and()
. So 'being always interpreted in the same way' isn't terribly important.</a pointless rant>
Admin
Not quite. Banks give out loans that bear interest act[ual]/360, meaning you pay 5-6 days extra interest each year. Interest on savings is usually either 360/360 or act/act.
Admin
You're right- I should have said: b = b will not return true.
Admin
You're right- I should have said: b = b will not return true.
Admin
Your group needs to redo its physics calculations. It will take a lot less rocket power to simply slow the Earth's spin so as to make 360 days a year. Plus that has the advantages of not contributing to global warming (it should actually cool us), andthe 24.35 hourd day that results is a better match to our own biological clock (which is about 25 hours).
Admin
Admin
I believe his comment about white space throwing an exception refers to the single line of white space in the try block, which would obviously never throw anything, hence WTF are you doing checking it?
My only possible explanation is that there used to be something there and it has since been removed, without removing everything else.
Of course, that still doesn't explain why you would recurse on error. (If it doesn't work the first time, try, try again.)
Edit: The real WTF is that the Quick Reply button on a post doesn't allow for quoting of the original post!
Admin
Apparently this is not an uncommon thing to comment...
muahahaha