LWN.net Logo

Advertisement

E-Commerce & credit card processing - the Open Source way!

Advertise here

Time representation

Posted Sep 13, 2006 20:39 UTC (Wed) by dark (subscriber, #8483)
In reply to: Time representation by rvfh
Parent article: What you should (and shouldn't) expect from 64-bit Linux (Linux.com)

the OS could have an unsigned number for its current epoch.

Not anymore, it can't :) Too many applications rely on it being signed. (And if you don't mind breaking those, then why not move to 64 bits instead?)

One reason they rely on it is that in addition to using time_t to represent dates, they subtract time_t values from each other to represent intervals.

For example:
while (deadline - time() > 15) { ... do something that might take 15 seconds ... }

If time_t is unsigned, this condition will be true if time() is already past the deadline, thus causing an infinite loop. Well, not really infinite... just 68 years :)


(Log in to post comments)

Copyright © 2008, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds
Powered by Rackspace Managed Hosting.