lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I don't know whether the time stamp is base 0 , maybe it count from a
very large number or a random number.
It used in many place, and the data type defined in protocol is 64bit.
I can't guarantee it never used on some unusual way. For example, the
high bits used for machine id in other place. The other parts of
system don't know the lua limits .

在 2012年4月12日 上午3:22,Xavier Wang <weasley.wx@gmail.com> 写道:
> let's think of how many years if you use 56bit integer to indicate time stamp:
>
> a year has 60*60*24*365.2422 seconds, i.e. 31556926s.
>
> so a 2^32 integer can indicate 2^32/31556926 == 136.10 year,
>
> so, if you use 32bit integer and use date from 1900, you will overflow in 2036.
>
> but a 2^56 integer can indicate 2^56/31556926 == 2283416130 year,
>
> so even you count time in us(1/1000000s), you still can indicate 2283 year.
>
> means you can indicate years from 0000 to 2283, which is mostly enough.
>
> so, just convert int64 time stamp to lua_Number, it's enough :-)
>
> 在 2012年4月12日 上午2:57,云风 <cloudwu@gmail.com> 写道:
>> It's not enough, because the time stamp is send by other process not
>> written in lua. The protocol define it is the int64 number.
>>
>> 在 2012年4月12日 上午2:05,Xavier Wang <weasley.wx@gmail.com> 写道:
>>> in this case, 56bit should be enough.
>>>
>>> 在 2012年4月12日 上午1:34,云风 <cloudwu@gmail.com> 写道:
>>>> We use int64 for a timestamp from outside ( read from a socket with
>>>> the protocol) , and we need preform arithmetic on it.
>>>>
>>>> 在 2012年4月11日 下午9:14,Xavier Wang <weasley.wx@gmail.com> 写道:
>>>>> and then you can put it into a string.
>>>>>
>>>>> 在 2012-4-11 晚上8:05,"steve donovan" <steve.j.donovan@gmail.com>写道:
>>>>>
>>>>>> On Wed, Apr 11, 2012 at 1:42 PM, Alex Queiroz <asandroq@gmail.com> wrote:
>>>>>> > Unless it's possible to create the IDs consecutively starting from 1.
>>>>>>
>>>>>> But they often come from outside, and Outside has its own logic ;)
>>>>>>
>>>>>> steve d.
>>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> http://blog.codingnow.com
>>>>
>>>
>>
>>
>>
>> --
>> http://blog.codingnow.com
>>
>



-- 
http://blog.codingnow.com