c# Math.Sqrt Implementation

后端 未结 4 1502
不知归路
不知归路 2020-12-17 20:08

I\'ve been using System.Math quite a lot lately and the other day I was wondering, how Microsoft would have implemented the Sqrt method in the library. So I popped open my b

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-17 20:30

    Google.com will give you more answers than StackOverflow.com

    Have a look at this page: http://en.wikipedia.org/wiki/Methods_of_computing_square_roots One algorithm can be found under the title " Binary numeral system (base 2)" in the above wiki page.

    But, software implementations will NOT be efficient. Modern CPU's have hardware implementations for math functions in FPU. You just need to invoke the correct instructions of the processor (in assembly or machine language)

提交回复
热议问题