Issue #16470 has been reported by andrykonchin (Andrew Konchin).

----------------------------------------
Bug #16470: Issue with nanoseconds in Time#inspect
https://bugs.ruby-lang.org/issues/16470

* Author: andrykonchin (Andrew Konchin)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 2.7
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
Recently in Ruby 2.7 nanoseconds were added to a string representation produced by the `Time#inspect` method.

I encountered an issue when was working on new specs for the RubySpec project - nanoseconds are displaying like a Rational.

Let's illustrate it with example:

```ruby
t = Time.utc(2007, 11, 1, 15, 25, 0, 123456.789)
t.inspect # => "2007-11-01 15:25:00 8483885939586761/68719476736000000 UTC"
```

But nanoseconds are stored correctly:

```ruby
t.nsec # => 123456789
t.strftime("%N") # => "123456789"
```

So `123456789` is formatted as `8483885939586761/68719476736000000` which equals `0.12345678900000001`.

I assume it isn't expected behavior and will be fixed.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>