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

What is needed to get this proposal moving? #22

Open
WORMSS opened this issue Jul 4, 2023 · 1 comment
Open

What is needed to get this proposal moving? #22

WORMSS opened this issue Jul 4, 2023 · 1 comment

Comments

@WORMSS
Copy link

WORMSS commented Jul 4, 2023

What is needed to get this moving?

I have not been able to find a working polyfill to have a base36 BigInt.. (That doesn't break on the input 10 which should be 36, but all the ones I found come out as 1)
Having something such as BigInt.fromString(input, 36) would help me greatly..

I have a string containing 58000+ 0 and 1
Which I have to manipulate with

const bigNum = BigInt(`0b${binStr}`); // Have to add 0b so BigInt knows its base2
const hexStr = bigNum.toString(16); // resulting in a 14000 character string;
/* this hex string gets transmitted over the network */
/* then on the otherside */
const bigNum = BigInt(`0x${hexStr}`); // Have to add 0x so BigInt knows its base16
const binStr = bigNum.toString(2); // Returns to the original binStr format.

It would be nice to do

const bigNum = BigInt.fromString(binStr, 2); // No dodgy 0b mess
const zStr = bigNum.toString(36); // resulting in a 10000 character string; (Saving 4000 chars)
/* this base36 string gets transmitted over the network */
/* then on the otherside */
const bigNum = BigInt.fromString(zStr, 36); // No dodgy 0z mess (since it doesn't exist, no way to specify its a base36 BigInt(input)
const binStr = bigNum.toString(2); // Returns to the original binStr format.
@WORMSS
Copy link
Author

WORMSS commented Jul 4, 2023

Ignore what I said about the no good polyfills, I seen what people was doing, and I reversed their math, and now it works..
But, still.. Having this built in would be nicer.
If I could 'toString' to a higher base than 36 would also be very beneficial to me resulting in shorter strings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant