{"action":"opened","issue":{"url":"https://api.github.com/repos/google/protobuf/issues/2881","repository_url":"https://api.github.com/repos/google/protobuf","labels_url":"https://api.github.com/repos/google/protobuf/issues/2881/labels{/name}","comments_url":"https://api.github.com/repos/google/protobuf/issues/2881/comments","events_url":"https://api.github.com/repos/google/protobuf/issues/2881/events","html_url":"https://github.com/google/protobuf/issues/2881","id":215501625,"number":2881,"title":"Ruby: Precision loss in float fields.","user":{"login":"landrito","id":8572251,"avatar_url":"https://avatars3.githubusercontent.com/u/8572251?v=3","gravatar_id":"","url":"https://api.github.com/users/landrito","html_url":"https://github.com/landrito","followers_url":"https://api.github.com/users/landrito/followers","following_url":"https://api.github.com/users/landrito/following{/other_user}","gists_url":"https://api.github.com/users/landrito/gists{/gist_id}","starred_url":"https://api.github.com/users/landrito/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/landrito/subscriptions","organizations_url":"https://api.github.com/users/landrito/orgs","repos_url":"https://api.github.com/users/landrito/repos","events_url":"https://api.github.com/users/landrito/events{/privacy}","received_events_url":"https://api.github.com/users/landrito/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-03-20T17:46:41Z","updated_at":"2017-03-20T17:46:41Z","closed_at":null,"body":"There seems to be precision loss when packing and unpacking floating point fields. This seems to have not been caught because the [test](https://github.com/google/protobuf/blob/master/ruby/compatibility_tests/v3.0.0/tests/basic.rb#L148-L149) tests a passing case (as shown below). \r\n\r\nAlso [double](https://github.com/google/protobuf/blob/master/ruby/compatibility_tests/v3.0.0/tests/basic.rb#L150)  is missing an assertion.\r\n\r\nFurther discussion can be found in [google-cloud-ruby/pull/1341](https://github.com/GoogleCloudPlatform/google-cloud-ruby/pull/1341).\r\n```rb\r\nrequire 'google/protobuf'\r\n\r\nGoogle::Protobuf::DescriptorPool.generated_pool.build do\r\n  add_message \"google.test.Float\" do\r\n    optional :floating_value, :float, 1\r\n  end\r\nend\r\n\r\nFloat = Google::Protobuf::DescriptorPool.generated_pool.lookup(\"google.test.Float\").msgclass\r\n\r\nf = Float.new\r\nf.floating_value = 0.1\r\np f.floating_value #=> 0.10000000149011612\r\n\r\nf.floating_value = 0.2\r\np f.floating_value #=> 0.20000000298023224\r\n\r\nf.floating_value = 0.3\r\np f.floating_value #=> 0.30000001192092896\r\n\r\nf.floating_value = 0.4\r\np f.floating_value #=> 0.4000000059604645\r\n\r\nf.floating_value = 0.5\r\np f.floating_value #=> 0.5\r\n\r\nf.floating_value = 0.6\r\np f.floating_value #=> 0.6000000238418579\r\n\r\nf.floating_value = 0.7\r\np f.floating_value #=> 0.699999988079071\r\n\r\nf.floating_value = 0.8\r\np f.floating_value #=> 0.800000011920929\r\n\r\nf.floating_value = 0.9\r\np f.floating_value #=> 0.8999999761581421\r\n\r\nf.floating_value = 0.0\r\np f.floating_value #=> 0.0\r\n```\r\n\r\n"}}
{"actor":{"display_login":"landrito"}}