Does anybody know how to convert a string
to a BigInt
without using the BigInt()
constructor or any other libs like math etc?
So, my task is to implement arithmetic operations on strings without relying on bigint
or arithmetic libraries. Can someone give me a hint?
Input is a valid string
with a positive number inside, output should be bigint
.
ChatGPT give me an answer with BigInt()
.
I tried to use typeOf()
operator (I don`t know am I allowed to use it).
2
Answers
I finally got my answer approved by my mentor.
You mean something like this?
NOTE: The numbers in the examples are exceeding MAX_SAFE_INTEGER