Advertisement

02.22.2007 at 05:43AM PST, ID: 22406155
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

5.8

conversion LARGE_INTEGER to _int64; or operating with LARGE_INTEGER

Asked by jutzki in C / C++ / C# Editors and IDEs, C++ Builder, Microsoft Visual C++

Tags:

Hello,
I am trying to use an alternative Sleep() function in C that has a better solution. (The solution of sleep() is only 15 ms). I need 1 ms. My teacher gave me the above code


static double esperaH(double *temp) //sleep in ms
{

bool resultado;
unsigned _int64 *now, *frec,goal;
//LARGE_INTEGER *now, *frec, goal;

now = (unsigned _int64*)calloc(1,sizeof(now));
//now = (LARGE_INTEGER*)calloc(1,sizeof(now));
resultado = QueryPerformanceCounter(now);

frec = (unsigned _int64*)calloc(1,sizeof(frec));
//frec = (LARGE_INTEGER*)calloc(1,sizeof(frec));
resultado=QueryPerformanceFrequency(frec);

goal = *now + (unsigned _int64)((*temp*1.0e-3)*(*frec));

while (goal > *now)
resultado = QueryPerformanceCounter(now);
return ((double)*now/(double)*frec)*1000;
//return ((LARGE_INTEGER)*now/(LARGE_INTEGER)*frec)*1000;

}

if I compile it like this I get the following warnings/errors:
--------------------Configuration: pci 1784 configuration5 - Win32 Debug--------------------
Compiling...
pci 1784 configuration5.cpp
C:\datos\judith\proyecto_judith\pci 1784\pci 1784 configuration5.cpp(110) : warning C4305: 'argument' : truncation from 'const double' to 'float'
C:\datos\judith\proyecto_judith\pci 1784\pci 1784 configuration5.cpp(55) : warning C4101: 'num_contador' : unreferenced local variable
C:\datos\judith\proyecto_judith\pci 1784\pci 1784 configuration5.cpp(387) : warning C4244: 'argument' : conversion from 'unsigned long' to 'unsigned short', possible loss of data
C:\datos\judith\proyecto_judith\pci 1784\pci 1784 configuration5.cpp(426) : warning C4244: 'argument' : conversion from 'const double' to 'unsigned char', possible loss of data
C:\datos\judith\proyecto_judith\pci 1784\pci 1784 configuration5.cpp(728) : error C2664: 'QueryPerformanceCounter' : cannot convert parameter 1 from 'unsigned __int64 *' to 'union _LARGE_INTEGER *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
C:\datos\judith\proyecto_judith\pci 1784\pci 1784 configuration5.cpp(732) : error C2664: 'QueryPerformanceFrequency' : cannot convert parameter 1 from 'unsigned __int64 *' to 'union _LARGE_INTEGER *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
C:\datos\judith\proyecto_judith\pci 1784\pci 1784 configuration5.cpp(737) : error C2664: 'QueryPerformanceCounter' : cannot convert parameter 1 from 'unsigned __int64 *' to 'union _LARGE_INTEGER *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.

pci 1784 configuration5.obj - 3 error(s), 4 warning(s)


If I compile it using _int

If I use the other code version:

static double esperaH(double *temp) //sleep in ms
{

bool resultado;
//unsigned _int64 *now, *frec,goal;
LARGE_INTEGER *now, *frec, goal;

//now = (unsigned _int64*)calloc(1,sizeof(now));
now = (LARGE_INTEGER*)calloc(1,sizeof(now));
resultado = QueryPerformanceCounter(now);

//frec = (unsigned _int64*)calloc(1,sizeof(frec));
frec = (LARGE_INTEGER*)calloc(1,sizeof(frec));
resultado=QueryPerformanceFrequency(frec);

goal = *now + (LARGE_INTEGER)((*temp*1.0e-3)*(*frec));

while (goal > *now)
resultado = QueryPerformanceCounter(now);
return ((double)*now/(double)*frec)*1000;
//return ((LARGE_INTEGER)*now/(LARGE_INTEGER)*frec)*1000;

}

...I get the following compiler warnings/errors:
--------------------Configuration: pci 1784 configuration5 - Win32 Debug--------------------
Compiling...
pci 1784 configuration5.cpp
C:\datos\judith\proyecto_judith\pci 1784\pci 1784 configuration5.cpp(110) : warning C4305: 'argument' : truncation from 'const double' to 'float'
C:\datos\judith\proyecto_judith\pci 1784\pci 1784 configuration5.cpp(55) : warning C4101: 'num_contador' : unreferenced local variable
C:\datos\judith\proyecto_judith\pci 1784\pci 1784 configuration5.cpp(387) : warning C4244: 'argument' : conversion from 'unsigned long' to 'unsigned short', possible loss of data
C:\datos\judith\proyecto_judith\pci 1784\pci 1784 configuration5.cpp(426) : warning C4244: 'argument' : conversion from 'const double' to 'unsigned char', possible loss of data
C:\datos\judith\proyecto_judith\pci 1784\pci 1784 configuration5.cpp(728) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
C:\datos\judith\proyecto_judith\pci 1784\pci 1784 configuration5.cpp(732) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
C:\datos\judith\proyecto_judith\pci 1784\pci 1784 configuration5.cpp(734) : error C2677: binary '*' : no global operator defined which takes type 'union _LARGE_INTEGER' (or there is no acceptable conversion)
C:\datos\judith\proyecto_judith\pci 1784\pci 1784 configuration5.cpp(736) : error C2678: binary '>' : no operator defined which takes a left-hand operand of type 'union _LARGE_INTEGER' (or there is no acceptable conversion)
C:\datos\judith\proyecto_judith\pci 1784\pci 1784 configuration5.cpp(736) : fatal error C1903: unable to recover from previous error(s); stopping compilation
Error executing cl.exe.

pci 1784 configuration5.obj - 3 error(s), 6 warning(s)


I don´t know what to do. The Query-fungtions seem to only accept large_integer, but large_integer cannot operate with +,*,/
Does anyone have a suggestion what could be my error or how I could solve my problem?? I would be so glad since I am very unexperienced in programming.

JudithStart Free Trial
[+][-]02.22.2007 at 06:14AM PST, ID: 18587543

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.22.2007 at 06:33AM PST, ID: 18587814

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.22.2007 at 06:34AM PST, ID: 18587819

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.22.2007 at 06:42AM PST, ID: 18587891

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.22.2007 at 06:52AM PST, ID: 18587983

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.22.2007 at 07:09AM PST, ID: 18588157

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.22.2007 at 07:18AM PST, ID: 18588248

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.22.2007 at 07:28AM PST, ID: 18588349

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.22.2007 at 07:29AM PST, ID: 18588367

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.22.2007 at 07:49AM PST, ID: 18588580

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.22.2007 at 07:56AM PST, ID: 18588653

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.22.2007 at 08:05AM PST, ID: 18588740

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.22.2007 at 08:16AM PST, ID: 18588896

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.22.2007 at 08:24AM PST, ID: 18588964

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.22.2007 at 08:43AM PST, ID: 18589154

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: C / C++ / C# Editors and IDEs, C++ Builder, Microsoft Visual C++
Tags: large_integer
Sign Up Now!
Solution Provided By: Kdo
Participating Experts: 3
Solution Grade: A
 
 
[+][-]02.22.2007 at 08:53AM PST, ID: 18589257

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.22.2007 at 09:24AM PST, ID: 18589544

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]02.22.2007 at 10:22AM PST, ID: 18590006

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.16.2007 at 12:27PM PDT, ID: 19299225

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]11.13.2007 at 03:47PM PST, ID: 20276501

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32