|
Thank you! That is indeed timely information. 
|
|
|
|
|
You're very welcome. Did it provide a feasible solution?
djj55: Nice but may have a permission problem
Pete O'Hanlon: He has my permission to run it.
|
|
|
|
|
As a matter of fact it did. I had to explicitly implement the OnMnemonic function to trap the accelerator and send it along as the character that it was supposed to be. Pretty clunky. I'm surprised that the interoperability is not better but I get that is what happens when HWND based dialogs are mixed with XAML based dialogs.
|
|
|
|
|
I thought I knew, but I was wrong.
double x0 = 1 / 0.0;
double x1 = 1 / -0.0;
double x2 = 1 / double.Parse("0.0");
double x3 = 1 / double.Parse("-0.0");
Obviously these are all going to be some sort of infinity (yes you can divide by zero[^], and the result is infinity). One might reasonably expect both x1 and x3 to be Negative Infinity .. however, only x1 is Negative Infinity. x3 is Positive Infinity, which is about as wrong as any answer could possibly be.
This implies that double.Parse blatantly ignores the sign of zero.
|
|
|
|
|
harold aptroot wrote: the sign of zero
Sounds like something Sherlock Holmes (or his smarter brother) would investigate.
|
|
|
|
|
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.
|
|
|
|