|
Well, the difference stands between a standard pointer and a smart one. The exact nature of the interface is irrelevant to the OP context.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Hello All,
Please go through the following piece of code which is giving problem.
#include <iostream.h>
void main()
{
int angle = 2330,angul_step=55;//change angul_step to 60
float nAngle = (float)(angle / 10) - 2;
float nAngulationStep = (float)angul_step / 100;
float nFrames = (int)(nAngle/nAngulationStep);
int nPhaseFrames = (int)nFrames + 1;
cout<<"The nFrames is "<<nFrames<<endl;
cout<<"The nPhaseFrames is "<<nPhaseFrames<<endl;
}
The out put is in Debug mode.
The nFrames is 419
The nPhaseFrames is 420
The out put is in Release mode
The nFrames is 420
The nPhaseFrames is 421
In the same way: If you change the angul_step to 60 and run the out put in Debug and Release mode are
Debug mode:
The nFrames is 384
The nPhaseFrames is 385
The out put in Release mode is
The nFrames is 385
The nPhaseFrames is 386
I have replace Float with Double:
The output are different.
Debug mode:
The nFrames is 419
The nPhaseFrames is 420
Release Mode:
The nFrames is 420
The nPhaseFrames is 421
In the same way: If you change the angul_step to 60 and run the out put in Debug and Release mode are
Debug Mode
The nFrames is 385
The nPhaseFrames is 386
Release Mode
The nFrames is 385
The nPhaseFrames is 386
Changing float to double works only for specific numbers. The problem is unknown to me.
Please let me know if any one had this experience and solution.
I need to calculate the value "ROUNDDOWN((Angle-2)/AngulationStep)+1"
where Angle will be ((angle/10) -2) and angulation Step would be angul_step/100.
Thanks much.
Kishore
|
|
|
|
|
Kishore JP wrote: float nAngle = (float)(angle / 10) - 2;
float nAngulationStep = (float)angul_step / 100;
I would change these to:
float nAngle = (angle / 10.0) - 2.0;
float nAngulationStep = angul_step / 100.0;
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
(1) please use <pre> tags to surround code snippets.
(2) the following line
float nAngle = (float)(angle / 10) - 2;
is probably wrong, replace it with
float nAngle = ((float)angle / 10) - 2;
or
float nAngle = (angle / 10.0) - 2;
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Kishore JP wrote: float nAngle = (float)(angle / 10) - 2;
(angle / 10) is first computed as integer , and the integer-result is converted to a float . Subsequently, an integer 2 is subtracted, thereby being inplicitly converted to a 2.0 float .
The resulting float is assigned to nAngle .
Kishore JP wrote: float nAngulationStep = (float)angul_step / 100;
A integer-division of angul_step by (integer)100 is done, and the (integer)result is convertetd to a float.
Kishore JP wrote: float nFrames = (int)(nAngle/nAngulationStep);
A float -division is done, its decimals are thrown away (that is: rounded down) and the result is implicitly converted into a float.
Numerics in C/C++ require you to really know what you want to do. If you want to divide by a float-constant, you really must write a float into your code (as the others already showed you)!
B.T.W. Why do you use float ?
Do your math in double and round when you need it (e.g. when handing coordinates over to OpenGL)
If you really must use warting (e.g. writing nAngle instead of simply Angle ), which is completely obsolete in the days of IDEs and Intellisense, please do it meaningful, and distinguish integers and decimal values.
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
I have resolved the issue by using the /Op compiler option. The problem is compiler is doing round up when it is getting the answer ( to any expression ) x.999xxxxx (x is any number). And it is storing the X+1 to the left side of the expression. When I do cast of this parameter i am getting the only X.
By using /Op flag for improving the consistency of floating-point tests.
You can test this by the example:
231/0.55= 420.
|
|
|
|
|
Fine that you solved it.
But remember that you are a bit compiler specific here: Neither ohter version of VisualStudo nor different compiler will necessary bring you the same result. Just keep that in mind or maybe create a unit-test for that.
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
Hi there
I have 2 questions:
- How can I know the handle ID of desktop window?
- How can I launch calc, or mspaint applications from my code and if that applications are already opened to activate them?
How to do this or where can I find such examples?
I'm working on MFC.
|
|
|
|
|
duta wrote: - How can I know the handle ID of desktop window?
Are you referring to GetDesktopWindow() ?
duta wrote: - How can I launch calc, or mspaint applications from my code and if that applications are already opened to activate them?
It really depends on how that particular application was coded. Some applications are coded such that they can only exist in memory one time. The first thing to try would be to use CreateProcess() to run the application. The next thing to try would be to use FindWindow() to search for the application's window. If it is found, use BringWindowToTop() .
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I think you said me dont use of FindWindow,right?
|
|
|
|
|
I need to add a button to my form which stops the process,
just like cancel button in install applications.
which way do i have to use?
please somei-one hel me!!!
|
|
|
|
|
Adnan Merter wrote: I need to add a button to my form which stops the process,
just like cancel button in install applications.
What process do you need to stop?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Adnan Merter wrote: I need to add a button to my form which stops the process,
So what do you need help with, adding a button, responding to a button click, or stopping a process?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
i need help about stopping the process
the prcess is driving a stepper motor
i mean the button must stop all actions while my program sending data to parallel port,
just like an emergency "stop button" or "cancel button in install application"
thanks
|
|
|
|
|
Ok, then you'll need at least one other thread for this. Do the work of communicating with the parallel port in the secondary thread. This will free up the primary thread to handle the UI. See here for the way to gracefully stop a thread.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Try some of the following depending on your compiler and environment.
standard:
exit(-1);
Microsoft:
ExitProcess(-1);<br />
TerminateProcess(GetCurrentProcess(),-1);
Microsoft Window:
PostMessage(WM_CLOSE,0,0);
|
|
|
|
|
Hello everyone,
As mentioned here,
http://msdn2.microsoft.com/en-us/library/cc266343.aspx
when we call DebugBreak, the program under \\HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\AeDebug key, will be invoked. The value for mine is,
"C:\Windows\system32\vsjitdebugger.exe" -p %ld -e %ld
In my environment, a dialog will be displayed and Visual Studio 2008 is the only item to select to debug. My question is, why vsjitdebugger.exe is not called as mentioned in MSDN, but Visual Studio 2008 is displayed in the dialog box?
thanks in advance,
George
|
|
|
|
|
What actually happens when you call DebugBreak (on an Intel x86 anyway) is the {int 3}instruction is executed. That's assembly for 'trigger interrupt number 3'. If an interrupt handler is installed for interrupt 3 it will be called. What happens after that is down to the interrupt handler. How to install one? Why Windows pops up the 'Choose a debugger' dialog when there's only one installed? These things are plenty mysterious.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Do you mean 'Choose a debugger' dialog is vsjitdebugger.exe? Matthew?
regards,
George
|
|
|
|
|
No but it might be, that would make sense of the registry entry. Next time it comes up have a look in your task manager and see if the vsjitdebugger process is running only when the dialog is displayed.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Yes, Matthew!
I have found vsjitdebugger in the process list. To be more confident, we need some formal documents to support.
regards,
George
|
|
|
|
|
On a "normal" user's system the default debugger creates a dump file and sends it to Microsoft (assuming you agree). When you install software development software such as MSVC the debugger is changed to the debugger which is part of the IDE so you can debug your software. I use .REG files to switch between various debuggers (WinDBG is extremely powerful but a little annoying to use, MSVC is easy to use but underpowered).
Steve
|
|
|
|
|
Thanks Steve!
Do you know whether the program with 'Choose a debugger' dialog is vsjitdebugger.exe?
regards,
George
|
|
|
|
|
|
Cool, Maximilien!
Question answered.
regards,
George
|
|
|
|