nim-lang / bigints

BigInts for Nim
MIT License
123 stars 32 forks source link

Support more characters for initializing a `BigInt` from a string #52

Closed konsumlamm closed 2 years ago

konsumlamm commented 2 years ago

Analogous to - for negative numbers, we could also support a leading +, which would be ignored. Another thing that would be nice is supporting _ (which also get ignored), akin to normal int literals:

let a = initBigInt("+10_000_000_000")
dlesnoff commented 2 years ago

We could also change the toString function. I would add optional parameters to toString to add _ and sign to the normal representation. By default the default parameters would not output them, so we can always get the number of digits in the specified radix representation by asking for len(number).