Python error when calling NumPy from class method with map

前端 未结 5 2207
春和景丽
春和景丽 2021-02-12 23:52

The following code throws me the error:

Traceback (most recent call last):
  File \"\", line 25, in 
    sol = anna.main()
  File \"\", line 17, in         


        
5条回答
  •  说谎
    说谎 (楼主)
    2021-02-13 00:23

    It may not be your exact case, but if you want to take the square root of a large number AND you want to have control of the precision of the result, going either to math.sqrt() or x ** 0.5 would not be much useful because your result will end up being a float number, and for large enough inputs, this will hit the limitations of float numbers.

    One possibility for the specific case of sqrt is to look into an integer-only implementation of the square root algorithm, e.g. flyingcircus.util.isqrt() (Disclaimer: I am the main author of flyingcircus).

    Alternatively, for a more general solution, one may look into gmpy (or any other arbitrary precision library with Python bindings).

提交回复
热议问题