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

Add byte-number conversion utilities to xod/bits #1186

Closed
4 tasks
nkrkv opened this issue May 3, 2018 · 0 comments · Fixed by #1240
Closed
4 tasks

Add byte-number conversion utilities to xod/bits #1186

nkrkv opened this issue May 3, 2018 · 0 comments · Fixed by #1240

Comments

@nkrkv
Copy link
Member

nkrkv commented May 3, 2018

Rationale

Bytes are only used to store and transfer data. On the other hand, numbers are more applicative. We need a sane way to convert between numbers and bytes. Let’s add a few nodes to xod/bits:

  • i8-to-number
  • u8-to-number
  • i16-to-number
  • u16-to-number (same as xod/core/word-to-number)
  • i32-to-number
  • u32-to-number
  • number-to-i8
  • number-to-u8
  • number-to-i16
  • number-to-u16
  • number-to-i32
  • number-to-u32

Here, i means signed and u is unsigned. The number denotes number of bits from the byte-data side. For example, number-to-i32 have a single number input and four byte outputs. The number is considered to be integer: a fractional part is truncated if present in the input.

To serialize numbers as is, let’s implement a couple of additional nodes:

  • ieee754-to-number — takes four bytes and returns a single number
  • number-to-ieee754

Prerequisites

#1185, #1187

Acceptance criteria

  • The nodes listed are implemented in xod/bits
  • The xod/core/word-to-number is deprecated
  • All new nodes are documented
  • All new nodes have table tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants