- 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
Do you think he wrote a program to automatically generate the code?
Admin
I refer you to my earlier comment:
http://thedailywtf.com/Comments/The-Percent-Conversion.aspx#373594
Admin
Solves the problem of "0.987", "0.9876"... all without wasting CPU cycles when the value is "0".
Admin
Admin
On Net Power? Laptops works well on net power with damaged batteries
Admin
What is faster?
- or - - or -Admin
TRWTF is the bad performance caused by the linear orientation of all those IF's. It could be drastically improved if arranged in a binary scheme!
Admin
This is why (Cr)Apple iPods only update their battery life at 90%, 80%, and 10%.
Admin
Can't believe you actually did it! Brilliant!
Admin
What other data type does "NA" fit in? What other data type does "1%" fit in for that matter?
No, the real WTF is that the results are not translated for the local culture and placement of % signs.
Admin
None of those will produce the same results as the function you're replacing. So does it matter?
Admin
ROFLMAO!!!!
Admin
That would do it, wouldn't it?
Admin
Those who propose a mathematical approach seem to be missing that the OP code will ONLY display if the ToString is an exact match.
Admin
New Requirement: Report to the nearest 10th of a percent... oops.
Admin
Admin
Meine Augen
Admin
The first one.
Admin
I'm genuinely curious as to how it isn't. If you're talking about it missing an "NA", then please tell me the impact of that on my original question.
Admin
Admin
FIRST!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
TRWTF is Akismet. Really.
Admin
Admin
looks like VB to me... and for some reason VB does not have ==
Captcha: oppeto - pedo op?
Admin
I briefly worked at a job where my boss came by and gave me a serious talking to because I had used a nested IF statement. We don't do things like that here, he explained. It's too difficult to understand. I was forced to re-write it using GOTOs.
Admin
I cried a little bit.
Admin
True, but I refuse to accept the idea that a goal of refactoring is to preserve all the existing bugs. Fix bugs ... crazy idea, I know.
Admin
Don't you just hate it when project managers and PHBs have a hard time understanding the code?
Admin
Admin
One of my most productive days was throwing away 1000 lines of code. — Ken Thompson
Admin
LOL yeah, people assume when we say TRWTF is language of choice, we don't use language of choice.
Admin
If they insist, give them a hex dump of the compiled object code, never the source code.
Admin
Admin
Should be:
Admin
I used to have an old Dell Latitude that had a modular bay for the CD-ROM that could be replaced with a second battery. One of the batteries was quite old, and its voltage reporting was messed up. According to Windows, the battery charge would drop from 100 to 0% in about 10 minutes, then continue to run (presumably from the other battery) for another hour at 0% while screaming to be plugged in.
Admin
Mozhet buyt ti krasivaya, na u menya zhenschina.
Admin
Fresh outta eggs = no preggers!
Admin
I swear, I hate programmers. A simple if(0==...) can handle the "NA" check and correcting precision takes even less keystrokes.
As, for those who are also curious to which one is best, my quick test seems to point to the first option. The 2nd and 3rd flip flop some times, but it is generally 2nd that wins out. This is the same for the 2 digit precision and whatever precision BatteryLifePercent returns.
Thanks for answering the meat of my question instead of picking nits.Admin
Admin
Also, why are the last 2 options around if just manually creating the string is faster? I would think they were super-optimized algorithms used to deprecate the good ol' way of doing it, but just appending the strings to each other is generally a 10-15% decrease in time.
CAPTCHA - acsi: What stupid retorts do you have for this question I'm acsi-ng?
Admin
Admin
What, and confuse it with all the other BatteryLifePercentStrings?
Admin
That will work 99.98% of the time.
Admin
Perhaps something out.
Admin
TNX
Admin
Admin
Admin
Or you might see something similar if the battery is charging.
NA
Admin
OK, that's just pseudocode--feel free to write a 'do while' loop in your language of choice.
Admin
Admin
Some reason? Is it becuase it descends from a (admittedly horrible) language that predates C?
The =/== silliness was introduced by Ken Thompson/and or Dennis Ritchie when they implemented "B", even though it was supposed to be derived from BCPL which seems to used the then conventional ALGOL style = for equality, and := for assignment.
For some reason they changed this, and introduced a myrid of unintended behaviours (bugs) and Yoda conditonals upon the world, as well as making a generation of Pascal trained programmers (like me) brains explode when they first saw it (why oh why oh why?)
Note - I'm not denigrating C - it's great for some things, only an abritary design decision made in the late 60s.