What is the value of time_ns() before it wraps?

119 views
Skip to first unread message

Jeffrey Sarnoff

unread,
Nov 24, 2016, 11:30:36 PM11/24/16
to julia-users
The help says "Get the time in nanoseconds. The time corresponding to 0 is undefined, and wraps every 5.8 years." I want to know the largest UInt64 value that time_ns() can return: the (nonzero) value which would be followed by 0x01%UInt64.

Jeffrey Sarnoff

unread,
Nov 25, 2016, 1:56:00 AM11/25/16
to julia-users
On Thursday, November 24, 2016 at 11:30:36 PM UTC-5, Jeffrey Sarnoff wrote:
> The help says "Get the time in nanoseconds. The time corresponding to 0 is undefined, and wraps every 5.8 years." I want to know the largest UInt64 value that time_ns() can return: the (nonzero) value which would be followed by 0x01%UInt64.

Doing the math results in 0x028a4486a830c000 (5.8 years of nanoseconds). That seems an unlikely max value -- which prompts this question.

Yichao Yu

unread,
Nov 25, 2016, 10:31:21 AM11/25/16
to Julia Users
The doc string is very old.
https://github.com/JuliaLang/julia/commit/5e627b214c3601c5772530878b64693e7b66be15
And I'm not sure if it is accurate anymore. It is very likely platform
dependent. On Linux it's using clock_gettime(CLOCK_MONOTONIC) and I
didn't find anything that suggests it'll wrap around that fast on
64bits or 32bits.

"The time corresponding to 0 is undefined" also does not mean the
value followed by 1 is the max value. It is 0, just that it does not
represent any particular time, neither does any other values it
returns.

This function also does not give ns precision. So most likely it'll
never return 1

Finally, please stop posting to this list and use
https://discourse.julialang.org/ instead.
Reply all
Reply to author
Forward
0 new messages