From: Mike Stok Date: 2002-09-15T08:46:16+09:00 Subject: Re: Time#+ and usec In article <8248e2a3.0209141306.7677f2d3@posting.google.com>, Michael Witrant wrote: > Hello, > > The following results look buggy. I tried with Ruby 1.6.7 and 1.7.2. > > (Time.at(0) + .1).usec # => 100000 > (Time.at(0) + .2).usec # => 200000 > (Time.at(0) + .3).usec # => 299999 > (Time.at(0) + .4).usec # => 400000 Smells like floating point arithmetic in action to me ... try [0.1, 0.2, 0.3, 0.4, 0.5].each { |f| puts '%.20f' % f } And have a look at http://docs.sun.com/source/806-3568/ncg_goldberg.html Hope this helps, Mike -- mike@stok.co.uk | The "`Stok' disclaimers" apply. http://www.stok.co.uk/~mike/ | GPG PGP Key 1024D/059913DA mike@exegenix.com | Fingerprint 0570 71CD 6790 7C28 3D60 http://www.exegenix.com/ | 75D2 9EC4 C1C0 0599 13DA