|
Souldrift wrote: CreateTimerQueueTimer(&hTimer, hTimerQueue, (WAITORTIMERCALLBACK)&DoSendHere, 0 , 9, 1, WT_EXECUTEINTIMERTHREAD);
You're asking for a timer with an initial delay of 9ms and periodic delays after that of 1ms.
Souldrift wrote: DeleteTimerQueueEx( hTimerQueue, NULL );
Think that should be DeleteTimerQueueTimer( hTimerQueue, hTimer, 0 ); . That worked for me, anyway.
Souldrift wrote: And why does it not call the callback func when I take away the sleepEx()?? Is it dependant on the thread being asleep?
The thread needs to be in an alertable state - look at the MSDN documentation[^] for what that means.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Souldrift wrote: it always jumps 15,6ms forward
I doubt the granularity and accuracy of the time value returned by ::GetSystemTimeAsFileTime() . Even though the FILETIME structure is a time value where the least significant bit represents 100 nanoseconds, it doesn't mean that it has an accuracy of 100 nanosecs.
It's like looking at your watch, measuring a time with the needle showing seconds and then multiplying the value by 1,000,000 and claim you measured with microsecond accuracy.
For time measurements of this kind you should you the performance timer; ::QueryPerformanceCounter() and ::QueryPerformanceFrequency() .
It will give you the best accuracy available on your hardware.
Read here[^] for more info on the high resolution performance counter.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
How can I make a trunc() function in C++,
Example:
trunc(7.1) = 7;
trunc(7.6) = 8;
|
|
|
|
|
What function? Just cast it to an integer. Or if you want a function:
__inline int trunc(float f)
{
return (int)f;
}
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
If I do it in this way, the results are:
trunc(7.1) = 7;
trunc(7.6) = 7;
|
|
|
|
|
Oh sorry, I overlooked your previous post. You can use one of those flooring or ceiling functions.
[Added] OK, Stuart just replied with a floor function at the same time. [/added]
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Presuming you want similar behaviour for numbers < 0
trunc(-7.1) = -7;
trunc(-7.6) = -8;
then this should work
int trunc(double d) { return floor(d+0.5); }
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
rounded_num = (int)(num + (num < 0 ? -0.5 : 0.5));
|
|
|
|
|
You call it trunc() , but that is the expected behaviour of round() function.
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]
|
|
|
|
|
I was guessing that the OP is trying to implement the functionality himself.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Your guess is right, I suppose. However, OP must not give, even to his functions, deceiving names, unless, of course, he is a Klingon programmer.
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]
|
|
|
|
|
you are looking for a rounding function
int round(double d)
{
return (int) (d + 0.5);
}
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
The FPU already does this for you.
inline int iround(double v){
int retval;
__asm fld qword ptr [v]
__asm fistp dword ptr [retval]
return retval;
}
inline unsigned int uround(double v){
unsigned retval;
__asm fld qword ptr [v]
__asm fistp dword ptr [retval]
return retval;
}
|
|
|
|
|
|
Hiii,,,
The following code doesn't take .
How to make it correct?
UINT64 ui_offset;
LONGLONG ll_array[ ui_offset];
Showing constraint error....!!!
Thank u
|
|
|
|
|
ui_offset has to be a constant.
Try this -
const UINT64 ui_offset = <value>;
LONGLONG ll_array[ui_offset];
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Hiiii....
I tried with
const UINT64 ui_offset = 1000000;
LONGLONG ll_array[ui_offset];
It works properly...
Thanking you......
|
|
|
|
|
What is woring in my following codes run time error is occuring for both code
int main()
{LPTSTR strResult;
LPTSTR strDefault=L"no";
DWORD d=255;
GetPrivateProfileString(L"data",L"Patchcab ",
strDefault,strResult,d,
L"D:\\TMP\\patchpolicy.ini");
printf("%s",strResult);
}
int main()
{
LPTSTR strResult=L"";
LPTSTR strDefault=L"no";
DWORD d=255;
GetPrivateProfileString(L"data",L"Patchcab ",strDefault,strResult
,d,L"D:\\TMP\\patchpolicy.ini");
printf("%s",strResult);
}
|
|
|
|
|
There is no memory allocated for the LpReturnedString parameter.
You're declaring it as LPTSTR strResult which is only a pointer.
You will need to do this -
TCHAR strResult[255];
DWORD d = 255;
Also change printf to _tprintf .
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
|
Hey, I think this is just a little mistake somewhere. I am new to using the STL algorithms, so i am totally botching it somehow.
My code looks like this:
typedef std::string Node;
typedef std::vector<Node> Cluster;
and down in the code i want to do this:
bool contains (const Cluster& cl, const Node& n)
{
Cluster::iterator it = find (cl.begin (), cl.end (), n);
(it == cl.end ()) ? return false : return true;
}
is that possible? or am i not allowed to do that? Thanks in advance!
|
|
|
|
|
Looks good except for the last return.
It should be return (it == cl.end ()) ? false : true;
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
«_Superman_» wrote: It should be return (it == cl.end ()) ? false : true;
return (it != cl.end());
FFY from me & Jijo.
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]
|
|
|
|
|
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Howdy'
I have some very bad code that should crash but I'm having difficulty figuring out why it does not crash (or even give out warnings); it works in VS2003 in release&debug and in VS2008 in debug, not in release.
class Info
{
public:
Info();
Info(std::wstring s1, std::wstring s2);
std::wstring m_string2;
};
struct myStruct
{
std::vector <Info*> m_JobInfoVector;
};
m_MyStruct = (myStruct*)malloc(sizeof (myStruct) );
ZeroMemory(m_MyStruct, sizeof(myStruct));
Info* p = new Info( std::wstring(_T("allo")) );
m_MyStruct->m_JobInfoVector.clear();
Question : What happens to the vector member when the ZeroMemory is called ? and why it does not crash in debug but it does in release ?
Thanks.
Max.
This signature was proudly tested on animals.
|
|
|
|