[ad_1]
Tags: india, news, modi, trump
2215 points, 170 comments.
[ad_2]
Humor | ReportWire publishes the latest breaking U.S. and world news, trending topics and developing stories from around globe.
[ad_1]
…sent us five wtfs. And so on anon.
Item the first, an anon is "definitely not qualified" for this job.
"These years of experience requirements are getting ridiculous."
Item the second unearthed by a farmanon has a loco logo.
"After reading about the high quality spam emails which
are indistinguishable from the company's emails, I got
one from the spammer just starting his first day."
In thrid place, anon has only good things to say: "I'm
liking their newsletter recommendations so far."
"A choice so noice, they gave it twoice," quipped somebody.
And foinally, a tdwtfer asks "I've seen this
mixmastered calendering on several web sites. Is there
an OSS package that is doing this? Or is it a WordPress
plugin?"
I have a sneaking suspicion I posted this before.
Call me on it.
[ad_2]
Lyle Seaman
Source link
[ad_1]
Antonio has an acquaintance has been seeking career advancement by proactively hunting down and fixing bugs. For example, in one project they were working on, there was a bug where it would incorrectly use MiB for storage sizes instead of MB, and vice-versa.
We can set aside conspiracy theories about HDD and RAM manufacturers lying to us about sizes by using MiB in marketing. It isn't relevant, and besides, its not like anyone can afford RAM anymore, with crazy datacenter buildouts. Regardless, which size to use, the base 1024 or base 1000, was configurable by the user, so obviously there was a bug handling that flag. Said acquaintance dug through, and found this:
const baseValue = useSI ? 1000 : 1024;
I know I have a "reputation" when it comes to hating ternaries, but this is a perfectly fine block of code. It is also correct: if you're using SI notation, you should do base 1000.
Now, given that this code is correct, you or I might say, "Well, I guess that isn't the bug, it must be somewhere else." Not this intrepid developer, who decided that they could fix it.
// const baseValue = useSI ? 1000 : 1024;
baseValue = 1024
if (useSI === false)
{
baseValue = 1000;
}
if (useSI === true)
{
baseValue = 1024;
}
It's rather amazing to see a single, correct line, replaced with ten incorrect lines, and I'm counting commenting out the correct line as one of them.
First, this doesn't correctly declare baseValue, which JavaScript is pretty forgiving about, but it also discards constness. Of course, you have to discard constness now that you've gotten rid of the ternary.
Then, our if statement compares a boolean value against a boolean literal, instead of simply if(!useSI). We don't use an else, despite an else being absolutely correct. Or actually, since we defaulted baseValue, we don't even need an else!
But of course, all of that is just glitter on a child's hand-made holiday card. The glue holding it all together is that this code just flips the logic. If we're not using SI, we set baseValue to 1000, and if we are using SI, we set it to 1024. This is wrong. This is the opposite of what the code says we should do, what words mean, and how units work.
[ad_2]
Remy Porter
Source link