lua-users home
lua-l archive

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


"Jérôme VUARAND" <jerome.vuarand@gmail.com> writes:
>> Doesn't this run into problems with precision if "float" is the basic
>> number type?  Actually if numbers are floats it seems that any
>> unix-like date representation will have problems...
>
> The problem already is also present with doubles. I made the following
> quick test, and it appears that about half numbers between one and one
> million get rounding errors with the conversion we are talking about
> (an integer in microseconds to a float in seconds).

Hmm, well since common fractional time units aren't exactly
representable with base-2 floats, you'd inevitably get some kind of
small error.  I don't know if that would actually be a practical problem
using doubles and representing typical time intervals, but as soon as
you try to use floats or represent absolute times, I think things get
pretty dicey...

-Miles

-- 
`Cars give people wonderful freedom and increase their opportunities.
 But they also destroy the environment, to an extent so drastic that
 they kill all social life' (from _A Pattern Language_)