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

Global.fromBigEndianBytes method #993

Open
aslesarenko opened this issue May 21, 2024 · 0 comments
Open

Global.fromBigEndianBytes method #993

aslesarenko opened this issue May 21, 2024 · 0 comments
Assignees
Labels
A-consensus Area: Code used in consensus (i.e. transaction validation) C-feature Category: Feature request or PR soft-fork Implementation requires soft-fork
Milestone

Comments

@aslesarenko
Copy link
Member

aslesarenko commented May 21, 2024

A new Global.fromBigEndianBytes[TNum] method should be implemented which can parse big-endian two's complement binary representation of TNum type.

The type TNum can be one of Byte, Short, Int, Long, BigInt.

Examples:

val shortBytes = Coll(0.toByte, 16.toBytes) 
val s = fromBigEndianBytes[Short](shortBytes) // using global pre-defined function
// assert (s == 16.toShort)

val intBytes = Coll(0.toByte, 0.toByte) ++ shortBytes
val i = Global.fromBigEndianBytes[Int](intBytes) // using method of Global
// assert (i == 16)

It should be mutually inverse to Numeric.toBigEndianBytes, so that, continuing the above example:

val isEqual = i.toBigEndianBytes == intBytes
// assert (isEqual)

Related to toBigEndianBytes in #486

@aslesarenko aslesarenko added soft-fork Implementation requires soft-fork A-consensus Area: Code used in consensus (i.e. transaction validation) C-feature Category: Feature request or PR labels May 21, 2024
@aslesarenko aslesarenko added this to the v6.0 milestone May 21, 2024
@aslesarenko aslesarenko self-assigned this May 21, 2024
@kushti kushti self-assigned this Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-consensus Area: Code used in consensus (i.e. transaction validation) C-feature Category: Feature request or PR soft-fork Implementation requires soft-fork
Projects
None yet
Development

No branches or pull requests

2 participants