How to implement square root and exponentiation on arbitrary length numbers?

Posted by tomp on Stack Overflow See other posts from Stack Overflow or by tomp
Published on 2010-12-25T22:52:33Z Indexed on 2010/12/25 22:54 UTC
Read the original article Hit count: 229

I'm working on new data type for arbitrary length numbers (only non-negative integers) and I got stuck at implementing square root and exponentiation functions (only for natural exponents). Please help.

I store the arbitrary length number as a string, so all operations are made char by char.

Please don't include advices to use different (existing) library or other way to store the number than string. It's meant to be a programming exercise, not a real-world application, so optimization and performance are not so necessary.

If you include code in your answer, I would prefer it to be in either pseudo-code or in C++. The important thing is the algorithm, not the implementation itself.

Thanks for the help.

© Stack Overflow or respective owner

Related posts about algorithm

Related posts about language-agnostic