Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Write an article for LinuxForums Today! Win Great Prizes!
Okay, new problem. (btw, thanks everyone for the help thus far.) My program does not seem to be comparing two 64-bit (unsigned long long) numbers properly. Here is a code snippet and its resulting printout:
The number in the printout look good (i.e. they are in the range I expect to see). However, the compare in the above 'if' statement did not work right. As you can see, the time passed is clearly more than the minimum expected time, so it should have passed. Does anyone know what is going on here? Is there some kind of magic code I need to use to make this work with 64-bit numbers?
I did a simple test on my x86_64 AMD system with the code below and it always returns passed for me. Not sure if anything is going on with the Failed() and Passed() functions, but I would just double check those.
Code:
#include <stdio.h>
main()
{
unsigned long long num1 = 23778603427;
unsigned long long num2 = 1280072496;
if (num1 < num2)
{ printf("Failed!\n"); }
else
{ printf("Passed!\n"); }
}
EDIT: Also tried this on my 32bit system and it works fine with no compiler errors or warnings.
Code:
#include <stdio.h>
main()
{
unsigned long long num1 = 23778603427ll;
unsigned long long num2 = 1280072496ll;
if (num1 < num2)
{ printf("Failed!\n"); }
else
{ printf("Passed!\n"); }
}
Thanks for the help. I think the problem was in the printf() statement I was using to display the minimum expected time. I accidentally used %u, when I should have used %llu.
Open Source Security Myths Dispelled Dispel the five major myths surrounding Open Source Security and gain the tools necessary to make a truly informed decision for your IT organization subscribe
InformationWeek InformationWeek is the only newsweekly you'll need to stay on top of the latest developments in information technology. subscribe