Re: erlang:monotonic_time() is negative
Jesper Louis Andersen <[email protected]> Tue, 1 Sep 2015 15:43:03 +0200
| Newsgroups | gmane.comp.lang.erlang.bugs |
|---|---|
| Message-ID | <CAGrdgiX_rcgiPhkT5FW--H4RwvUP7o3ERN54ve30fKVFOeOESw@mail.gmail.com> |
On Tue, Sep 1, 2015 at 2:20 PM, Sergej Jurečko <[email protected]> wrote: > Using 18.0.3 on OS X 10.10.5. I even tried rebooting the machine to check > if the time turns negative after a while, but it seems it is always > negative. > > erlang:monotonic_time(). > -576460736152226213 > This is the normal behavior. In order to use the full 60 bit signed value, it is custom to start at a negative number when starting a new Erlang node: 1> os:type(). {unix,freebsd} 2> erlang:monotonic_time(). -576460743520961806 1> os:type(). {unix,sunos} 2> erlang:monotonic_time(). -576460744933281955 And so on. You can only use monotonic_time() for doing checks relative to itself, as in: B = erlang:monotonic_time(), do_work(), E = erlang:monotonic_time(), Elapsed = erlang:convert_time_unit(E - B, native, micro_seconds), ... As Loic writes, check the document on time and time correction. -- J. _______________________________________________ erlang-bugs mailing list [email protected] http://erlang.org/mailman/listinfo/erlang-bugs