Skip to content

Base 36 constructor #48

Open
Open

Description

@WORMSS

Hello, For input, you have 0b101010101010 and 0xa6e etc etc..

You have the ability to do const b36 = BitSet('10101010110101010101010101010').toString(36)
But not sure how to get it back in const bs = BitSet(b36)

I am sure you are gonna say it's not possible.. but I just wanted to confirm that something like BitSet(b36, 36) didn't exist?

Activity

  1. infusion commented on Jun 1, 2023

    @infusion
    Collaborator

    Well, Bitset.js has two static functions BitSet.fromHexString and BitSet.fromBinaryString. Currently there is no option for an arbitrary base, but I think it would be a nice addition. Maybe something like BitSet.fromString(str, base)`, what do you think?

  2. WORMSS commented on Jun 1, 2023

    @WORMSS
    Author

    Constructor, static function, I am easy either way.. ❤️

    I was just looking through your parse(P, val) to see if it was possible.. I got a little confused by the len = 8 for hexidecimal part, so I was unsure what would be needed for passing in 36 or even arbitrary lengths..

  3. infusion commented on Jun 1, 2023

    @infusion
    Collaborator

    The len is just max block length, that is cut out at each time. For base 2 it's 32, for 16 it's 8, for a general base b it would be Math.log(2**32) / Math.log(b). However, this only makes sense for 2^k-bases with the current implementation. And I think implementing a static function is much cleaner, instead of coming up with an arbitrary prefix, such as 36:XYZ or something.

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

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