Bug #12980
closedTime - Time to return a Rational
Description
Currently subtracting a Time from a Time returns a Float, which I guess causes #12952
Is there any reason this doesn't return a Rational?
Updated by matsuda (Akira Matsuda) about 8 years ago
Well, my assumption seems wrong.
0.5r.round also becomes 0, so this isn't really related to #12952
Still I'm wondering why Time - Time isn't Rational though.
Updated by duerst (Martin Dürst) about 8 years ago
- Subject changed from Time - Time to return a Retional to Time - Time to return a Rational
Updated by akr (Akira Tanaka) about 8 years ago
It is because ruby-dev:38446 by mame-san.
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-dev/38446
Updated by akr (Akira Tanaka) about 8 years ago
- Status changed from Open to Feedback
Updated by mame (Yusuke Endoh) about 8 years ago
I think of one philosophical reason and one practical reason.
A philosophical reason: many Time objects are inherently inexact. Since a Rational is considered exact, returning a Rational might convey the wrong message that the Time objects are exact.
A practical reason: Time is often used for a simple benchmark tool. Consider "t = Time.now; ...; p Time.now - t
" prints, such as (631882841/200000000)
or (1590642983/500000000)
. It is difficult for human to read and compare the result.
Updated by matsuda (Akira Matsuda) about 8 years ago
- Status changed from Feedback to Closed
All right. Sounds rational. Thank you for the explanation, Mame-san and akr-san!