From ad203bcb2be17e06909ab6d67ab2475673673bbc Mon Sep 17 00:00:00 2001 From: Andreas Eger Date: Sun, 11 Dec 2016 03:30:08 +0100 Subject: fix floating point accuracy problem in Timestamp#to_f `.quo` return the most exact devision which fixes accuracy problems for the timestamp coercion --- ruby/lib/google/protobuf/well_known_types.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ruby/lib') diff --git a/ruby/lib/google/protobuf/well_known_types.rb b/ruby/lib/google/protobuf/well_known_types.rb index 547de874..921ddbc0 100644 --- a/ruby/lib/google/protobuf/well_known_types.rb +++ b/ruby/lib/google/protobuf/well_known_types.rb @@ -80,7 +80,7 @@ module Google end def to_f - self.seconds + (self.nanos.to_f / 1_000_000_000) + self.seconds + (self.nanos.quo(1_000_000_000)) end end -- cgit v1.2.3