- 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
Hey masklinn your avatar makes me think WTF!? :-)
Admin
Using _ to prefix private variables isn't a bad naming convention, it's a Python naming convention to denote a variable as private.
It doesn't enforce it as private, (Python: We're All Consenting Adults) so you can violate it at will, but it's considered bad form to do so.
Admin
This code is so awesome that I actually find myself offended... Yet still strangly turned on...
Admin
Hehe. It's an interpretation of "Firefox" I'm quite fond of, by ToyBoxArts's Toy, check out the "full" version, it's really nice
Private python is dual underscores ;) and although it can be violated you still have some name mangling done.
Admin
That's "Maze of twisty little casts, all alike"...
And I, for one, find it quite inspiring. It's one of those "once you've seen it, it's obvious" things. We've all seen (and probably, at some point, done) our share of pointless casts and conversions, and once you've seen this, you could obviously do much better (or rather, worse)... But the original idea, to use no less than FIVE conversions for a methode that does nothing else... and on top of that, shouldn't even exist because the input type is totally unfit to represent a date... I couldn't have come up with that.
Admin
Wow... imagine the sort of WTFs you could write if you were not limited to 2^64 cases in a switch statement!
(I wonder if this will quote correctly now that there's no preview button. It never worked for me before, even though I didn't click the button. Oh cool... I love the error I get when I forget to delete one of the inner quote tags... 'Something didn't quite work out ... ')
Admin
You could quickly implement calculations based on atom positions in the entire galaxy.
That rules.
Imagine an array of stars information, storing the visible universe!
Admin
did somebody already say "brillant"?
Admin
Delphi uses floats for representing DateTimes too. But truely I don't really see a problem with it?
Admin
Give this man a carrot.
Think about the phrase 'type checking'. Does it include object types as well as primitive types? I think it does.
Just because the syntax isn't c-like doesn't mean it isn't part of the language. *Any* arbitrary-length integer must be behaving as a structure in memory terms anyway. It can't be zero-terminated like a string, can it?
J.
Admin
The lack of precision inherent to floating point arithmetics and representation in computers?
Admin
You can store about 15 digits of information in a double before it clips, while in integer you would not be able to store but 11 digits. It's the integers that suffer from "lack of precision", in this case.
There's nothing inherently imprecise about floating point values. The perception arises simply because floats that are based on base-2 system hold other values exact than humans, who use base-10 system. Humans are not impressed to discover that floats can't represent a value such as 0.1 exactly but end up with something like
However, think about this: if we were using a base-3 system we'd have no trouble to represent 1/3 exactly. The value would be written as simply 0.1. So what's happening here, could it be that the decimal system is "inherently imprecise", too, because it doesn't have accurate representation for 0.333...
Admin
There is an unwritten rule here to not exceed the initial WTF. It makes you look very silly. Go maintain a Perl script, you 'Python is not any sane modern language'-ist!
Admin
I'm no mathematician, but compared to base-2, a base-3 system wouldn't really fare better when representing, say, 1/7 right?
Admin
That was his point, no number base system is perfect. Base-10 also wouldn't do any better with 1/7 than base-2 or base-3. However in base-7 1/7 could be exactly represented as 0.1. That said, base-7 would have real problems with 1/2.
We just take for granted that base-10 cannot and does not represent some fractions exactly. When base-2 comes in and represents some precisely and others not we take offence that they're different from the ones that base-10 does.
Admin
now if we only had computers with infinite memory, we could do a brillant implementation of natural numbers.
Admin
Uh, no, 11 digits in an integer are stored exactly as they've been inputted, and 20ish digits in int64, while you can't be sure (unless you do all the calculations to get the precise mapping of your float and only input floats that will match with your platform's floats representation) that the memory representation of a given float will be exactly what you inputted.
Yes there is, floats represent Real numbers, they're discrete values trying to emulate continuous data sets, can't match, imprecision. Integers are discrete values storing discrete data sets, exact match, precision.
Admin
Speaking of bignum functionality, I recently learned the .NET framework has (to my knowledge) no built-in functionality for bignum math. Looking through a couple of forums revealed people taking Java BigInteger-code and converting it to C# to get the desired functionality. WTF!?
Admin
All this talk of base-2 and base-10 not being perfect is why I've always advocated we switch to base-9699690. Not only is it pretty cool looking, but it easily represents such numbers as 1/3, 1/7 and even 1/19th perfectly. Honestly, its the only sane solution to the whole base issue. It cannot handle 1/23rd exactly, but to do so would require base-223092870 which would just be plain silly.
Admin
I know you're trying to be smart and edgy, but floats have no precision problems as a date storage - they only need 7+8 digits of precision. (3652500 days in the epoch, 86400000 msec a day.) Doubles have a 17 digit precision before calculations even start to break down, which is quite a ways from the 15 dates use. They won't have the sub-microsecond precision of a 64-bit DateTime of course.
And whether they're the most efficient, and whether directly adding days is worth it, is another story entirely.
Admin
I think I'm gonna patent this base-1 idea I've just had.
Admin
Use fractions structs (consisting of numerator and denominator, of course using arbitrary length bigints) instead of floating points and you have perfect representation for all rational numbers.
Admin
So what's the down side to "inadvertantly talking about the other" or even that the flaw<o:p></o:p> exists? Have you been burned by this coupling?
Admin
while you're at it you should get this date converting "algorithm" patended :)
Admin
...or rather that it's done in an ad hoc manner. I can see that it would create confusion for language implementors but like most certifications, for a specification or technical skills certification, it doesn't provide the value you would hope while in the process obtaining it. I have received a couple Java certifications over the years and don't believe I have received any jobs as a direct result of them. Likewise, if an platform isn't Java version x certified, it's likely not going to significantly influence my decision to use it or not.
Admin
double, yes. but float only has slightly less than 7 digit precision, and this therefore inadequate. And float is what the WTF code uses.
Admin
Certainly not all of them, since "arbitrary length" bigints are limited as well, e.g. java.math.BigInteger internally uses an array of regular ints, which has a maximum size of 2^31.
It all boils down to us (and our hardware) living in a finite universe, while there is an infinite number of rational (or even just integer) numbers.
Admin
Maybe someone has already mentioned this, but using floating point numbers for dates actually has some advantages over ints/longs.
For example, Unix timestamps are measured in the number of seconds since an epoch. As computers got faster, we got code that would care what millisecond the code is executed in. You can't measure that with a system that has only the granularity of seconds. Java uses something very similar to a Unix timestamp, the number of milliseconds since the same epoch (think of it as (Unix_timestamp)*1000L). But there's no way of getting the current time down to the nanosecond with a date stored this way. Using doubles, you'd have the ability to easily expand granularity (until you hit 17 digits).
I suspect that this is a very good thing for games and multimedia applications, that have to do things in real time.
But then again, I've never really researched this so my whole post here could be a WTF itself. :)
Admin
But, what happens to irrational numbers like sqrt(2) and pi?
Admin
Irrational? They go work for management.
Admin
By all means -- it can be downloaded at CommunityServer.org. I was really hoping removing the PREVIEW button would stop those "html" posts, but I guess not.
I may upgrade to V1.2 one of these days. Doubt it'll fix most things though.
Admin
Alex, wouldn't it be possible to just switch to another, more stable, less crappyJavascript ridden softwares?
I mean, most people here probably don't need the fancy editor (that doesn't work) and would more like... prefer a software that works as a whole, and allows you to middle click, and all that.
PunBB, for example, is a very lightweight forum which looks like it can behave the way TDF behaves (only better), has a quite clean frontend code allowing for a lot of CSS tuning, and is blazingly fast...
I don't know if you can post raw HTML in it though.
Admin
I don't care. There's not that many of them.
Admin
You're misinterpreting my statement. I was stating that even though python has unlimited length integers, you still can't say that "any sane modern language" does.
Admin
Calculate 100000000 + 0.000000001 in a double and tell me floating point numbers aren't imprecise.
BigInt is not part of the Java language, it's part of the Java standard library. Take J2ME, for example: it's still Java, but it doesn't have parts of the standard library, including BigInt.
Just in case you're _not_ joking: No, there's an infinite number of them.
Admin
Uh.. You're joking right?
Admin
Yeah, just read PEP 800 and found that out. I never knew! [:O]
*cough* gammy smilies *cough*
Admin
<joking>Oh really? How do you know? Have you counted them?</joking>
Admin
The serious answer is: a program running on a digital computer will never ever encounter an irrational number in finite time, so unless you do symbolic calculations, there is no need to consider them.
Admin
It's nice to see I'm not the only one who feels the DailyWTF forum code IS a wtf.
1. Preview buttons removed
2. font settings barely work correctly
3. no way to edit posts that YOU own, not even within a given grace period
Admin
Sorry man, figured you were joking, just hard to tell sometimes
Admin
Well,
if type is "native" to a language, one can use in as a const in source and compiler magic does the rest. Like
const int A = 5;
const double B = 10;
Now, please show me how one could write constants like that for "native" bigints in Java (or, C#, for that matter)?
LP,
:Piki
Admin
final BigInteger A = new BigInteger("100000000000000000000000000000");
Not sure what your point about "compiler magic" here is, though.
Admin
That's not a constant.
It's instance being created dynamically at runtime.
LP,
:Piki
Admin
So why do you think the difference is so important?
Admin
The
keyword actually does create a constant value in Java, the keyword has been reserved in Java5 (never had been before) but it's not used yet...So what Brazzy said is perfectly true, to get a constant Bigint in Java you just declare it as "final BigInteger".
Oh, and btw you can't create any language enforced constant in Python, though you can trick the language into creating "somewhat constants" with recipes such as this one. Does that mean that Python actually has 0 native types?
Admin
I think when he said "constant" he meant "literal"