You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuweni.apache.org by GitBox <gi...@apache.org> on 2022/11/22 05:04:13 UTC

[GitHub] [incubator-tuweni] siladu opened a new issue, #448: toShortHexString should return "0x0" for 0.

siladu opened a new issue, #448:
URL: https://github.com/apache/incubator-tuweni/issues/448

   I might be wrong but I believe toShortHexString contains a bug for the zero value.
   
   It's correct according to this test case but I'm not convinced the test case is correct:
   https://github.com/apache/incubator-tuweni/blob/ef737ec675997da710735e9b7acba87755f2a290/bytes/src/test/java/org/apache/tuweni/bytes/CommonBytesTests.java#L446
   
   I would also argue that trimLeadingZeros should also return "0x0" for 0 since zero isn't a _leading_ zero.
   
   I came across this for UInt64 but may apply to other datatypes. 
   
   Please could I get confirmation if this is a bug or not?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@tuweni.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tuweni.apache.org
For additional commands, e-mail: dev-help@tuweni.apache.org


[GitHub] [incubator-tuweni] ajsutton commented on issue #448: toShortHexString should return "0x0" for 0

Posted by GitBox <gi...@apache.org>.
ajsutton commented on issue #448:
URL: https://github.com/apache/incubator-tuweni/issues/448#issuecomment-1323075951

   It largely depends on the requirements for serialisation.  In RLP a UInt64 of 0 is actually a byte string (because RLP doesn't have numbers) so is serialised as `0x`.  In JSON-RPC Quantities trim leading zeros _except_ for the zero value so 0 is represented as `0x0`. So there's isn't really one "right" answer.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@tuweni.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tuweni.apache.org
For additional commands, e-mail: dev-help@tuweni.apache.org


[GitHub] [incubator-tuweni] siladu commented on issue #448: toShortHexString should return "0x0" for 0

Posted by GitBox <gi...@apache.org>.
siladu commented on issue #448:
URL: https://github.com/apache/incubator-tuweni/issues/448#issuecomment-1323080935

   > In RLP a UInt64 of 0 is actually a byte string (because RLP doesn't have numbers) so is serialised as 0x
   
   That's fair and I can see how toShortHexString might have different requirements depending on if you want to serialize to RLP or JSON.
   
   I would still argue trimLeadingZeros is either a misleading name or behaviour. Maybe it makes sense for the RLP scenario, but it could be more explicit about it in the name as for me that was unexpected behaviour.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@tuweni.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tuweni.apache.org
For additional commands, e-mail: dev-help@tuweni.apache.org


[GitHub] [incubator-tuweni] siladu commented on issue #448: toShortHexString should return "0x0" for 0

Posted by GitBox <gi...@apache.org>.
siladu commented on issue #448:
URL: https://github.com/apache/incubator-tuweni/issues/448#issuecomment-1326948396

   Thanks @atoulme I'll close this as it's clearly been considered and is intentional.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@tuweni.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tuweni.apache.org
For additional commands, e-mail: dev-help@tuweni.apache.org


[GitHub] [incubator-tuweni] siladu closed issue #448: toShortHexString should return "0x0" for 0

Posted by GitBox <gi...@apache.org>.
siladu closed issue #448: toShortHexString should return "0x0" for 0
URL: https://github.com/apache/incubator-tuweni/issues/448


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@tuweni.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tuweni.apache.org
For additional commands, e-mail: dev-help@tuweni.apache.org


[GitHub] [incubator-tuweni] siladu commented on issue #448: toShortHexString should return "0x0" for 0

Posted by GitBox <gi...@apache.org>.
siladu commented on issue #448:
URL: https://github.com/apache/incubator-tuweni/issues/448#issuecomment-1323099671

   Happy to close this as a non-issue since I can use `UInt64.getBytes().toQuantityHexString()` instead. I'll leave this issue open for a couple of days in case there's further comment


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@tuweni.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tuweni.apache.org
For additional commands, e-mail: dev-help@tuweni.apache.org