lua-users home
lua-l archive

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


Glenn Maynard wrote:
On Wed, Jun 15, 2005 at 02:54:23PM -0400, Aaron Brown wrote:

Glenn Maynard wrote:


However, all of this goes away if you avoid floating-point
entirely.

And use 64-bit ints instead?  (Or bignums?)


Yep.  Integers are much more easily predictable than floating-point: no
control word to enable unexpected exceptions, change the rounding
order or precision, no loss of precision due to unexpectedly large
values, results are predictable to the bit--they're much better suited
to measuring fine timings than floating point.

(Of course, not all systems have 64-bit ints, but not all systems
have doubles, either.  Since this is inherently x86-specific, nonportable
code, that's not much of an issue.  For portable code, I usually use
one 32-bit int for seconds, and one for micro- or nanoseconds.)


Actually all machines can have all these data types, it's just a simple matter of software :-)

For me, I really need to use doubles for two reasons. 1) it is the only practical datatype understood by Lua and 2) it is easier for content authors (non-programmers) to understand 1.5 seconds than 1500000 microseconds.

--
chris marrin                ,""$,
chris@marrin.com          b`    $                             ,,.
                        mP     b'                            , 1$'
        ,.`           ,b`    ,`                              :$$'
     ,|`             mP    ,`                                       ,mm
   ,b"              b"   ,`            ,mm      m$$    ,m         ,`P$$
  m$`             ,b`  .` ,mm        ,'|$P   ,|"1$`  ,b$P       ,`  :$1
 b$`             ,$: :,`` |$$      ,`   $$` ,|` ,$$,,`"$$     .`    :$|
b$|            _m$`,:`    :$1   ,`     ,$Pm|`    `    :$$,..;"'     |$:
P$b,      _;b$$b$1"       |$$ ,`      ,$$"             ``'          $$
 ```"```'"    `"`         `""`        ""`                          ,P`
"As a general rule,don't solve puzzles that open portals to Hell"'