1

I am trying to perform a relatively simple operation (square-root) using python 3.6 on a rather large integer as follows:

import math
y = math.sqrt(y_square)
print(y_square)
print(y)
print(y**2 - y_square)

Which yields:

y_square = 112453967836240530612698821058629451437284506947138273586752978210411860041664976976388128300702880194729095784116728402767535807027702758336085695030907730304293242710204005540029929073563476552311529976337882620026357537308679
y = 3.353415689058554e+113
y**2 - ysquare = 2.1040543606193494e+211

Although I've looked into int overflow given te size of my numbers, i've read that python3 do not have a size limit for int as they are defined with an arbitrary precision.

All in all, I simply do not understand why I get a 212-digits number as a result of my difference when I would have wanted... 0.

Thank you in advance for your help!

Clara-sininen
  • 191
  • 2
  • 9
  • From [python's documentation](https://docs.python.org/3/library/math.html#module-math): `The following functions (...) [e]xcept when explicitly noted otherwise, all return (...) floats.` – silel Apr 25 '17 at 11:12

0 Answers0