Thursday, April 21, 2011

How long is a .NET DateTime/TimeSpan tick?

How long is a .NET DateTime/TimeSpan tick?

From stackoverflow
  • The tick is the unit of granularity for the .NET DateTime and TimeSpan value types.

    It has the following common conversions:

    1 tick * 1E+2 = 100         nanoseconds
    1 tick * 1E-1 =   0.1       microseconds
    1 tick * 1E-4 =   0.0001    milliseconds
    1 tick * 1E-7 =   0.0000001 seconds
    
    Lance McNearney : You answered your own question one minute after posting it?
    Dan Fuller : -1 badge farming
    Allen : uh, StackOverflow encourages this sort of thing in the FAQ, dont down vote him for that. see: http://stackoverflow.com/questions/18557/how-does-stackoverflow-work-the-unofficial-faq#119658
  • Although currently a tick is 100 nanoseconds, it is best not to rely on this as an absolute. Rather, use 'TimeSpan.TicksPerSecond' (or any of the other TicksPerXxx member values)

    binarycoder : This is true. Don't hard code these in your code. However, they are absolute and will not be changed by Microsoft. The reason for this post is that sometimes one needs to do this math on a calculator and I wanted to make this chart available.

0 comments:

Post a Comment