now() and arithmetic

Matthias Lang matthias@REDACTED
Sat May 4 12:32:24 CEST 2002


 > Does anyone have some prebuilt routines for manipulating now() tuples, or
 > for converting them into C style seconds-since-blah values?

 > Alternatively can someone tell me the max size of the MicroS/S/MegaS
 > integers, so I can tell when it should overflow from one to the other (and
 > then I'll build some routines)?

Looking at emulator/beam/bif.c, all three are 'small' integers, which
should mean that they're 28 bits wide. 

Looking at emulator/beam/erl_time_sup.c, in the get_now() function, 
the second counter cannot be more than 999999. The microsecond counter
depends on gettimeofday(2) behaviour. The linux manpage for this implies
that the microsecond count will never exceed 999999.

Keep in mind that now() does 'interesting' things if you rapidly
change the system time. If you really want to know what the system
thinks the time is, then time/0 may be a better choice.

Matthias



More information about the erlang-questions mailing list