Floats in ruby/protobuf are not in fact equal
The existing test is misleading: https://github.com/protocolbuffers/protobuf/blob/82e83ddc95330bbd988ba874ea5aa37d343d4490/ruby/tests/common_tests.rb#L39-L40
This change adds a new test making the difference between ruby and protobuf floats explicit.
Something else to consider is currently the assignment of a ruby float returns the float with ruby precision. Perhaps the setter should return the float with protobuf precision?
Interesting; this test exposes a behavior gap between the JRuby and JRuby FFI variants; the FFI-based implementation (with the passing test) uses the same C-based implementation under the hood, but the legacy JRuby implementation is built on top of the Java Protobuf jar and fails.
@haberman - does Java Protobuf handle float precision differently, or is this specific to JRuby's use of it?
@haberman - does Java Protobuf handle float precision differently, or is this specific to JRuby's use of it?
I suspect this is specific to JRuby's use.
I suspect that JRuby is caching the Ruby object in this.fields when the user calls m.optional_float = 0.5. Then m.optional_float is returning the user's cached object, which will have the original precision since it was not actually derived from the Java message's value.
We triage inactive PRs and issues in order to make it easier to find active work. If this PR should remain active, please add a comment.
This PR is labeled inactive because the last activity was over 90 days ago. This PR will be closed and archived after 14 additional days without activity.
We triage inactive PRs and issues in order to make it easier to find active work. If this PR should remain active or becomes active again, please reopen it.
This PR was closed and archived because there has been no new activity in the 14 days since the inactive label was added.