I'm creating a simple timer class which returns me eg the current time in millis. On linux I'm using gettimeofday. I'm wondering what return type this function should have. ie double getMillis()
or uint64_t getMillis()
etc... I would say uint64_t
can hold bigger values and therefore recommended, though while googling I see lots of different implementations.
Any advice on this?
Thanks
我建议使用毫秒表示绝对时间戳的数据类型是int64_t,主要是因为对time_t进行了签名。
I would go with the unsigned integer type since the number of milliseconds is a count. Makes adding and subtracting dependable without float as well. Most implementations I have used has unsigned integer types.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.