Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Message type Int64 and UInt64 are greater than Number.MAX_SAFE_INTEGER #103

Closed
qiuzhong opened this issue Sep 18, 2017 · 5 comments
Closed

Comments

@qiuzhong
Copy link
Collaborator

The Int64 and UInt64 message type use string as the data property for inside representations. This might not a problem. However, part of numbers in this size are greater than Number.MAX_SAFE_INTEGER. So the data precision may be lost when delivering a Int64 or UInt64 number from publisher to subscription.

@minggangw
Copy link
Member

We'd better combine this with #51

@minggangw minggangw added this to the M3 milestone Sep 19, 2017
@minggangw
Copy link
Member

The maximum integer JavaScript can represents is Number.MAX_SAFE_INTEGER, which is 2^53 - 1. But ROS can use uint64_t to represent a value, which has maximum value of 2^64 - 1.Considering the fact that rclcpp and rclpy can support UInt64 message and the compatibility problem, I think we'd better reserve the actual value of UInt64 in string by leveraging the ref, thus user can get the correct value in string instead of cutting of the value or throwing an exception, also user should have the consciousness that the maximum integer is Number.MAX_SAFE_INTEGER in JavaScript when using parseInt.

@minggangw minggangw modified the milestones: M3, M4 Sep 29, 2017
@minggangw
Copy link
Member

I suggest maintaining the compatibility with other ros clients, which have the ability to represent Int64/UInt64. To achieve this, we have to store the int value as a string and let the user balance the interest, when the actual value is greater than Number.MAX_SAFE_INTEGER.

@minggangw
Copy link
Member

Let me close this issue as we don't want lost any information from other client when using Int64/UInt64, and the caller should be aware of using a string to represent the Int64/UInt64 value.

@qiuzhong
Copy link
Collaborator Author

It's acceptable as the JavaScript integer implementation limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants