开发者

Fastest method implementing number sqare root in string (1000000 digits)

What is fas开发者_如何学Pythontest algorithm implementing a square root of decimal contained in strings. This decimal can have 1000000 digits.

Anyone can tell me something about it?


Newton's method should work fine for you: Square Root for Bigint in F# .

Newton's method requires big decimal division. A somewhat simpler method which requires only squaring is just binary search on the square root.


Use 'lsqrt' (Just google for some code) and adjust it for your number type. I used the same approach to deal with big numbers in IronScheme.

Seems to work well.

Edit:

This returns an 'integer' root and a remainder.


BigSquareRoot

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜