|
Do you mean IEEE-754? C++ do use IEEE-754 to store the floating point numbers. In fact the floating point number format are implemented at the hardware level and Intel processors use IEEE-754.
-Saurabh
|
|
|
|
|
<blockquote class="FQ"><div class="FQA">Trupti Mehta wrote:</div>IEEE756</blockquote>
Never head about. Do you mean IEEE 754 ?
Trupti Mehta wrote: I believe the data types of C++ and Java are based on same whereas of Fortran double precision is based on IEEE756. I want to know how to convert these double precision calculations into C++ normally. For example:
double precision d1 = 0.3648564D0;d1**2 // ** indicates exponentDSIN(d1) // sin of double precisionDCOS(d1) // cos of double precision
Even if the FORTRAN double precision would based on a different standard, I believe the results of both programs (i.e. the FORTRAN and the Java one) should be comparable. Are you sure the logic of your translation is correct?
Have you made a test to compare the results (given by FORTRAN vs Java ) of such simple functions as sin and cos ?
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
[My articles]
|
|
|
|
|
Is this safe?
inline void YieldMessages( int milliseconds, int sleepTime = 50 )
{
DWORD targetTime = GetTickCount()+milliseconds;
while ( GetTickCount() < targetTime )
{
AfxGetApp()->PumpMessage();
Sleep(sleepTime);
}
}
I wrote this when I was having trouble getting a CWinThread to shutdown. This let's me post a WM_QUIT and wait for the thread to terminte....
I've always wondered if it might be a hack...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<a href="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</a>
|
|
|
|
|
Peter Weyzen wrote: I've always wondered if it might be a hack...
Mmm, it is a hack.
What you normally do when waiting for a thread to finish is to wait on the thread handle with a call to any of the wait functions such as ::WaitForSingleObject() . There you also have the possibility to provide a timeout value.
To be able to do that you first create your thread suspended and then set the CWinThread::m_bAutoDelete member to FALSE before unleashing the thread with a call to CWinThread::ResumeThread() . This prevents the CWinThread object from doing a "delete this " when the thread finishes, otherwise the thread handle will become invalid since the handle will be closed in the CWinThread destructor call chain. Of course this means that you have to destroy the CWinThread object yourself when the thread has finished.
Since it's a UI-thread you post a WM_QUIT message to the thread and then wait on the thread handle. When the thread finishes, the wait function will return and then you can delete the CWinThread object.
This excellent article[^] is absolutely worth reading when it comes to multithreading. Even though the article refers to worker threads explicitly, the mind set is very much the same for UI-threads when shutting down apart from the WM_QUIT message.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Thanks for all the information....
In general, threading's not an issue for me.
It's just dealing with CWinThread that bothers me. I can't say I like it very much.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<a href="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</a>
|
|
|
|
|
Peter Weyzen wrote: In general, threading's not an issue for me.
It's just dealing with CWinThread that bothers me. I can't say I like it very much.
That doesn't really make sense. CWinThread is just a thin wrapper around a
Windows thread. Nothing fancy there. You're still responsible for using
proper thread synchronization, which is much more safe and efficient than
using hacks like you showed above
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi all,
I have this code that creates threads with just one handle name Handle_Of_Thread_1, the code creates as much as 3 threads at the same time, my question is if there are 3 handles of the same name can I close them just once or do i have to close them 3 times?
Thanks,
Jayjay
|
|
|
|
|
What do you mean by handle name? A handle is just a number. In any event, you should close any handle that you create.
|
|
|
|
|
Hi Mike,
This function is being called more than once:
bool CUpdateData::DownloadFile(RMUpdates* prd)
{
bool result = false;
Handle_Of_Thread_1 = CreateThread( NULL, 0, Thread_no_1, ((void*)prd), 0, NULL);
if ( Handle_Of_Thread_1 == NULL) ExitProcess(1);
Sleep( 100 );
return result;
}
Now my question is that how many times should I close Handle_Of_Thread_1, lets say all the threads are done doing their job.
Thanks,
Jayjay
|
|
|
|
|
That's not very smart because you don't have any handle to the first created threads anymore, only the last one (it is a bit like a pointer, if you store another address in it, you loose the previous one).
By the way, what do you mean be close ? You should TerminateThread, but let the thread close nicely (e.g, you set a flag that specifies the thread should finish and the thread will react on this flag and stop nicely).
Also, It seems your code doesn't make a lot of sense: you are starting a new thread to download something (as far as I understood) but then you sleep 100 msec (probably to wait until the thread has finished its work) and then return the result. This doesn't make any sense: why are you creating a thread if this is done sequentially, there's no added value in having a thread doing that. Furthermore, there's a race condition here: if the sleep finishes before your thread has done its work, then you will return a wrong result.
|
|
|
|
|
Hi Cedric,
Do you have an example on how to do the flags you are recommending? I commented out the sleep already.
Thanks,
Jayjay
|
|
|
|
|
monsieur_jj wrote: Do you have an example on how to do the flags you are recommending? I commented out the sleep already.
Maybe I misunderstood your code, but what is the result that you return supposed to mean ? You always return false. Also, you call ExitProcess if you can't create the thread, are you sure you want to do such a thing ?
Anyway, here is a good article[^] that you should read in order to understand a bit more how to use threads.
|
|
|
|
|
Hi All
I have a abc.cpp and abc.h.I have do some work on ButtonClick.I have also some code in header file.Now i want to call ButtonClick in header file.I am useing like this
Cabc domodal;
domodal.ButtonClick();
But i am geting error.Can any one tell me how can i call it.
Plz help me
|
|
|
|
|
what error are you getting???
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/xml>
|
|
|
|
|
Error is
CAbcDlg' : undeclared identifier
missing ';' before identifier domodal
domodal' : undeclared identifier
left of '.OnBnClickedButton5' must have class/struct/union
|
|
|
|
|
are you creating CAbcDlg in CAbcDlg class?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/xml>
|
|
|
|
|
Are you sure you want to do such a thing ? Are you aware that the dialog box is not displayed and if you try to access something from the dialog box inside the ButtonClick function, you will get a crash ?
What are you trying to do in fact ?
|
|
|
|
|
You message's title does NOT look promising.
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
[My articles]
|
|
|
|
|
have you tried:
#include "abc.h"
and:
Cabc.DoModal();
Bram van Kampen
|
|
|
|
|
I have an App, with several identical USB Printers of the same type of the same manufacturer. Each of them has a Specific Task, which cannot be interchanged. Windows (for some reason does not seem to have envisaged this, and I) cannot keep track of Who'Who. I get Three Identical Printers to select from on the Printer Dialog. No way of saying Which is Which! I think my best bet would be to track the serial numbers. Does anyone know how.
Regards,
Bram van Kampen
|
|
|
|
|
sorry, just saw this (you cross posting ? tut tut) - I asked on the other reply how they were connected .. hmmmm, USB .. well, you still have to talk to a printer driver at some stage or through Windows to them ....
|
|
|
|
|
Have you tried WMI? The WMI Win32_Printer class has a DeviceID member
which is supposed to be unique.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
hmm - I tried WMI. DeviceID is same as Name.
The name, however, can be changed in the Control Panel/Printers
settings.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
#include <windows.h>
#include <stdio.h>
#include <detours.h>
#include
#include
#include <math.h>
#include <process.h>
#include <mmsystem.h>
#include <tlhelp32.h>
#include <vector>
//icludes are they
windows.h ;stdio.h;detours.h;math.h;process.h;vector;mmsystem.h;tlhelp32.h
#pragma comment(lib, "glu32.lib")
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "winmm.lib")
#define Client_GLDRAWELEMENTS 0x4E5DA2
#define CAST( Type, Address ) ( ( Type )( Address ) )
typedef void ( WINAPI *GLDRAWELEMENTS_TYPE )( GLenum iMode, GLsizei iCount, GLenum iType, const GLvoid *pvIndices );
GLDRAWELEMENTS_TYPE g_dwGlDrawElements = NULL;
void WINAPI glDrawElementsHook( GLenum iMode, GLsizei iCount, GLenum iType, const GLvoid *pvIndices )
{
( g_dwGlDrawElements )( iMode, iCount, iType, pvIndices );
}
DWORD OpenGLHooks( PVOID pvArgs )
{
do
{
g_dwGlDrawElements = *( DWORD * )Client_GLDRAWELEMENTS;
Sleep( 100 );
} while( g_dwGlDrawElements == NULL );
*( DWORD * )Client_GLDRAWELEMENTS = PtrToUlong( glDrawElementsHook );
return NULL;
}
bool WINAPI DllMain(HINSTANCE hDll, DWORD dwReason, PVOID pvReserved)
{
if(dwReason == DLL_PROCESS_ATTACH)
{
CreateThread( NULL, 0, ( LPTHREAD_START_ROUTINE )OpenGLHooks, NULL, 0, NULL );
return true;
}
else if(dwReason == DLL_PROCESS_DETACH)
{
}
return false;
}
|
|
|
|
|
Please, post the exact error message and tell us which line of code is the problem.
|
|
|
|