Skip to content

Offer conversion with Natural. #678

@kindaro

Description

@kindaro

A task one sometimes has to deal with is to take a number and look at the bytes it is made of. In other words, a number can be seen as an array of bytes. Specifically, there is a one to one inlay of numbers into byte strings and its inverse from byte strings back to numbers. It would be convenient if such a pair of functions could be found in this package.

There are two ways to encode a number into an array: least or most significant bit first. We can pick whichever is faster. There is also some confusion as to whether the encoding of 0 should be an empty byte string or a lonely zero byte. Neither is more mathematically principled than the other — we can pick whichever is more handy for our algorithm.

I think there is a linear time algorithm for either most significant or least significant digit first. But we can talk about implementation details once the design is agreed upon.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions