Blogging From Delphi to C#

Name:
Location: Struggletown, Planet Earth, Afghanistan

Software developer with a background in multimedia, video, Delphi and C#. Now working with Ruby on Rails and Adobe Flex (the future of Web apps IMHO)

Sunday, January 15, 2006

Will the Windows high resolution timer ever overflow ?

The windows high resolution timer is a 64 bit value of an unknown frequency. From experience, the frequency is often 500KHz. I need to represent a null value, and I was wondering whether -1 would be safe ie would the count ever actually equal -1 after an overflow ?

If the count starts at zero on boot, and can count to 2^31 and counts at 500Khz, how many years until it overflows ?

From Slickedit's trusty calculator :

2**63= 9223372036854775808
9223372036854775808/500000= 18446744073709.551616
18446744073709.551616/(3600*24*365)= 584942.41735507203247082699137494
584942.41735507203247082699137494

In 584942 years, it will overflow. I think its safe ;^8