|
That's your opinion. Others (including me) would find it logical that zero cannot be negative.
Some languages allow 2 different zeroes. I find it particularly annoying when x is negative when I expect it to be zero.
|
|
|
|
|
Well the problem is not so much that zero can't be negative, because zero can be negative in C#, if it has a floating point type.
The problem I have with this is that it's inconsistent and weird that writing a certain number in the source and parsing it from a string give different results.
Not even just some least-significant bit, but the sign. That's a pretty big deal.
modified 4-Aug-13 15:49pm.
|
|
|
|
|
I understand what you mean now, but i tried it on ideone.com and x3 is -Infinity
|
|
|
|
|
Hm yes, me too..
Well, they do use Mono instead of the MS version, that could be it
|
|
|
|
|
Others may find it logical that zero cannot be positive.
Seriously though, floating-point numbers are defined by an international standard (IEEE 754) that allows for +0 and -0. They have well defined meanings. Wiki[^]
The problem here is that while the language respects these, double.Parse fails to.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
Ah, C#, negative zeores in floating points but I can't say why the parser ignores it.
Negative zeores exist in computer only? Ever heard of the term negative zeroes?
Beauty cannot be defined by abscissas and ordinates; neither are circles and ellipses created by their geometrical formulas.
Carl von Clausewitz
Source
|
|
|
|
|
Did you try this:
double y0 = -0.0;
double y1 = 1 / y0;
Does it give +nfty or -nfty?
I ask because your x1 looks like this to me:
double x1 = -1 * 1 / 0.0;
Greetings - Jacek
|
|
|
|
|
That should give Negative Infinity, and it does.
|
|
|
|
|
Horror accepted.
Greetings - Jacek
|
|
|
|
|
Feds are gonna investigate and file a report on whoever has done this heinous crime ...
|
|
|
|
|
You know that feeling when you do something stupid and don't realize it until you've beat your brain to mush trying to fix it?? Yeah, try this on for size. Creating a converter to import images from a database (.BMP of all things!!) to something a bit more DB and web friendly, like PNG. Of course, I want to see the resulting images:
using (Bitmap newBitmap = targetBytes.ToBitmap())
{
...
TargetPictureBox.Image = newBitmap;
...
}
The targetPictureBox just showed a nice big red X. For 2 hours I couldn't figure out why this code worked yesterday but didn't work today! I accidently put the using block around the wrong bit of code!
|
|
|
|
|
Dave Kreskowiak wrote: The targetPictureBox just showed a nice big red X. For 2 hours I couldn't figure out why this code worked yesterday but didn't work today!
I was hoping the reason was going to be "the picture was a big red X". Oh well. (Then again, if that was the case, it wouldn't quite belong here I guess.)
|
|
|
|
|
I was looking to a web site that a team mate developed and found this briliant function
<script type="text/javascript">
function callPostBack() {
if (1 == 2)
return true;
else
return false;
}
</script>
What would you say to that "developer" ?
|
|
|
|
|
well, considering the language, i can't bash him...
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
"Given the chance I'd rather work smart than work hard." - PHS241
"'Sophisticated platform' typically means 'I have no idea how it works.'"
|
|
|
|
|
I'd say since it's JavaScript, use === instead of == .
/ravi
|
|
|
|
|
Good call.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I would possibly mention it to him in passing.
I have learned to no longer ridicule code no matter how idiodic that it appears, because I may just be belittling the code to the person that wrote it. Plus, I have come across my own mistakes that appear almost as brilliant as the example you have posted. I can only imagine started an idea, and never returned to that piece of code.
To know and not do, is not yet to know
|
|
|
|
|
Looks like code intended for debugging.
|
|
|
|
|
agreed
I do not fear of failure. I fear of giving up out of frustration.
|
|
|
|
|
I would ask why first? Perhaps there used to be a condition they were checking for and then at some point found out they didn't need it. It's easier to modify this one function then stop calling it from everywhere it could be used.
I would have expected a comment in it though, if that were the case.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
"What kind of debugging technique it is?" That's my first thought.
During debugging I would routinely put code like this to make debugging easier:
if(i == 4)
i = 4;
or
if(n == nullptr)
i = i;
|
|
|
|
|
Exactly.
Good and Bad code are created one line at a time.
This happens to be a chunk of forgotten code.
To know and not do, is not yet to know
|
|
|
|
|
Mladen Janković wrote: if(i == 4)
i = 4;
Was "4" chosen by a fair dice roll[^]?
Greetings - Jacek
|
|
|
|
|
Well, to take a point from a previous thread, it has one too many return statements.
Ducks and runs for cover.
At least I stay consistent.
Mark "So old school, Socrates was in his first year teaching." Johnson
Don't like the shot clock, the three point shot, or the designated hitter either.
|
|
|
|
|
MarkTJohnson wrote: one too many
It's much worse than that; it has fully twice as many as required!
|
|
|
|