|
I've just run it and it's outputting false. How have you declared NC, NX and NY - I tested it with double and int and it returned false in both cases.
|
|
|
|
|
Hi, NC, NX, and NY are locals with values arrived at by calling functions C and L
double NC = C(X,Y);
double NX = L(X);
double NY = L(Y);
double.IsNaN((NC / (Math.Pow(NX, 0.5) * Math.Pow(NY, 0.5))))
now returns true, for example when NC=1, NX=NY=2, as shown in the debugger. I should stress that these are not the only values of NC,NX, and NY which produce this strange result, it happens on a range of different (and apparently valid values) and not consistent - I only get the problem on some evaluations so I guess there is something outside the code presented here but I really have no idea where to start to look!
stegzz
|
|
|
|
|
Change it to:
double NC=1;
double NX = 2;
double NY = 2; When I ran this, the NAN check returns false.
|
|
|
|
|
Yes, this works as you say, so I suppose this points to the conclusion that the values shown in the debugger are not the ones which are being used when IsNaN returns true.
How can I work out what values are actually being evaluated and why doesn't the debugger show them?
|
|
|
|
|
Use System.Diagnostics.Debug.WriteLine and write the values to the output window.
|
|
|
|
|
Math.Pow(a, b) gives NaN if (but not only if) a is less than zero but not NegativeInfinity and b is not an integer and not infinite.
Which means, in this case, that if one or both of NX or NY are less than zero but not NegativeInfinity, you get a NaN.
NC can make it NaN if NC=NX=NY=0.
And of course the entire thing will be NaN if any of the inputs are NaN.
The values shown by the debugger must somehow be wrong.
|
|
|
|
|
The debugger stops on the return, right after checking IsNaN(S)
double S =(NC / (Math.Pow(NX, (double)0.5) * Math.Pow(NY, (double)0.5)));
if (double.IsNaN(S))
return 0;
And the debugger values for NC, NX, and NY are 1,2, and 2, respectively, so as suggested there is something wrong with the values being shown in the debugger.
Any ideas how to find out what the real values are that go into the calculation of S?
The code works fine when tested alone, in isolation from the rest of the program.
Thanks, stegzzz
|
|
|
|
|
Are there other variables named NC or NY that you or the debugger might confuse for each other? That is often what goes wrong.
Or is there any threading going on that might change NX or NY?
I'd put a break on the line that does the calculation, and hover over the various parts of the expression there (instead of looking in the locals window).
Btw, I get the expected result of S = 0.5
|
|
|
|
|
Is there any sample code or article based on Asp.net nested Accordion menu which drives values from sql server.
|
|
|
|
|
Probably lots, did you try looking at the articles pages[^] here on CodeProject, or typing your question into Google?
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Yes.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
i already done web page but i have a problem..now i have 2 web page window which is button window and graph window....so, i want to make button and graph in a window..the graph always refresh...how can i do that?
|
|
|
|
|
Your question is not very clear, and would probably be better in the ASP.NET or Web Development forums.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
|
when I start run remoting It show problem:
No connection could be made because the target machine actively refused it 127.0.0.1:8080
how can Fix this Problem...Thank in advanced
|
|
|
|
|
Try remoting to a machine (IP address and port) that will accept your request. Do you have a process listening on port 8080 of your own machine? I assume you understand that 127.0.0.1 is the loopback address.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
there is debate in my local office as whether or not we would benefit from migrating from C++ to C# to work with our SQL Server database.
currently we are using MS SQL Server Express R2 as a test model and making connections and doing some stored procedure work from C++ front end. Eventually, we will work in our customer's environment of the full fledged Microsoft SQL Server.
Can I get some feedback/opinions on the pros and cons of each - C++ and C# ?
Thank you,
JJ Mackey
|
|
|
|
|
If you're using ADO.net with either then there shouldn't be much difference.
My first experiences with SQL Server was with C++ and ODBC to access SQL Server 6; I hope you're not doing that.
|
|
|
|
|
Currently, i am using C++ with ADO commands. My programming team maintains several thousand lines of code in C++ (Visual Studio 2008) and there are roughly 1K-3K lines that interact with external databases in the Microsoft SQL Server environment.
The majority of the system(s) code we maintain don't perform SQL Server interaction - maybe 25% will interact with SQL Server.
Maybe i'm missing the difference between ADO and ADO.net. Also, back to the original question, what do i gain if i choose C# over C++ ?
Most of the team knows C++/MFC and we are clueless on C#.
Thanks.
|
|
|
|
|
john john mackey wrote: what do i gain if i choose C# over C++ ?
Undying gratitude from Microsoft?
john john mackey wrote: Most of the team knows C++/MFC and we are clueless on C#.
Then stick with what you know.
|
|
|
|
|
I don't think there is any difference from the database POV, I doubt there is any difference from the connection and interaction POV either. I'd be astonished if changing from C++ to C# made the slightest difference, changing from ADO to ADO.Net "may" make some slight difference.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks for the insight. Now I must look at the differences/advantages of ADO.net v ADO.
Regards,
John John
|
|
|
|
|
ADO.net (DataAdapters and suchlike) is quite nice. And you also have the potential of an entity management system like Entity Framework or NHibernate. However, that's not likely to be practical on a large existing database, and once you've written the queries, things aren't that different.
If you were starting a new project from scratch I'd advise using C# but the gains are not going to pay back the massive cost of moving an existing system, particularly if your team would have to start learning from the ground up.
|
|
|
|
|
Thank you for your comment and some topics to investigate regarding ADO.net.
Yes, the learning curve and porting our existing system is an important consider for staying with C++.
- John John
|
|
|
|
|
john john mackey wrote: Can I get some feedback/opinions on the pros and cons of each - C++ and C# ?
That isn't logical.
You can't make a technological decision wildly. It needs to be based on your business needs.
Some possible considerations.
- You have a team of 10 C++ senior developers with no C# experience. And the application meets all of the current business needs. And the C++ developers want do continue using C++. So the ONLY decision is to keep using C++.
- You have a team of 10 C++ developers with varying experience levels in C++ and C#. The application meets all of the current business needs. But 5 developers with the most business knowledge are threatening to quit unless you start using C#. So the only decision is to use C#.
- Your largest customer produces 80% of your business income and insists that you use either C++ or C#. So that is what you use.
- Your largest customer produces 80% of your business income and insists that you implement a feature that can only be implemented in either C++ or C#. So that is what you use. (This is probably a stretch scenario.)
- Your business plan calls for you selling the company to Microsoft. Then use C#.
- Your business plan calls for you selling the company to Oracle. Then use C++. Or Java. Regardless re-write to use Oracle instead of SQL Server.
- Your application is 1000% slower than it should be. You have a design/architecture/requirements problem. It has NOTHING to do with language choice.
- etc, etc, etc...
|
|
|
|