Click here to Skip to main content
15,885,914 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello developers,

I have a legacy 16 bit application written in C which outputs the system time in UTC format (Unix epoch time).

The following is the code snippet:
C
time_t  t ;
printf("%ld\n", time(&t)) ;


There is a difference between the time displayed in seconds on 16 bit and 32 bit application built with 16 bit and 32 bit Microsoft CL compiler for the above code.

Can anyone explain why the difference occurs?

For example here is the example executed at the same time,
32 bit:1404391074
16 bit:1404436063

Thanks,
Vishnu
Posted
Comments
W Balboos, GHB 3-Jul-14 9:08am    
What did you input as the time value for these? A fixed value or clock-time? The latter will never give you the same value twice in a row.
Vishnu Vardhan 3-Jul-14 9:11am    
Thanks for the reply.

Input is clock time. latter not be same but the difference might be in seconds. Here the difference is huge.
W Balboos, GHB 3-Jul-14 10:07am    
An experiment, if you haven't yet done so: convert the time back.
OK - now find out what each of the two compilers calls it year-zero, that is, convert zero back to a representation of time (or some other common value).

You're using common sense (that they should both give the same value) - but if you can dig up the documentation for the compilers, see if MS did what it was supposed to do, meeting the standards. Either could have been incorrect, but internally consistent for a given application (at least for all those built with same compiler).

(Sort of hand-waving).
Jochen Arndt 3-Jul-14 11:50am    
You may pass the time_t t variable to gmtime() and print the result to see if it shows the same difference of about 12.5 hours.

Which 16-bit compiler version you are using? The time() function is part of the C standard library and the 16-bit version is probably very old. Maybe that old version can not handle current dates correctly.

1 solution

Representation of data types varies between 16 bit and 32-bit compiler. Also time() function can't give you the exact/accurate time.something would be different because of factors like CPU load,ALU operations, no of Applications running, how any processes running, time slice for each process...etc.
So I hope it'll vary.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900