Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It depends on the implementation. CPython is using math functions from the standard C library. Jython is most likely using Java's math methods. And so on.</p> <p>In fact, Python has nothing to do with the actual implementation of math functions. Those are more related to IEEE 754 which is used almost exclusively to represent floating point numbers in computers nowadays.</p> <p>Anyway, speaking in terms of CPython, its <code>math</code> module is just a thin wrapper over C functions (<a href="http://docs.python.org/library/math.html" rel="nofollow noreferrer">prooflink</a>, at the bottom of the page). The C functions are implemented as part of the standard C library. It is usually included in OS distributions and it is most likely distributed in binary form, without sources. Note also that many microprocessors have specialised instructions for some of these operations, and your compiler may well make use of those rather than jumping to the implementation in the C library.</p> <p>I can't tell you the exact algorithm which is used in the standard C library on your system. Some of the possible algorithms are explained <a href="http://en.wikipedia.org/wiki/Methods_of_computing_square_roots" rel="nofollow noreferrer">here</a>.</p> <p>In the specific case of OS X, the math functions live in <code>libSystem.dylib</code>, which unfortunately is not Open Source (there is only <a href="https://opensource.apple.com/source/Libsystem/Libsystem-1238/" rel="nofollow noreferrer">stub code available on Apple's Open Source site</a>). You can however disassemble it if you are interested - on current systems, try e.g.</p> <pre><code>otool -tvV /usr/lib/system/libsystem_m.dylib </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload