开发者

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

开发者 https://www.devze.com 2022-12-28 16:35 出处:网络
What is fas开发者_如何学Pythontest algorithm implementing a square root of decimal contained in strings.

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

精彩评论

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

关注公众号