Using numpy to square value gives negative number

后端 未结 2 1869
小蘑菇
小蘑菇 2020-12-19 11:33

I\'m trying to use numpy to element-wise square an array. I\'ve noticed that some of the values appear as negative numbers. The squared value isn\'t near the max int limit.

2条回答
  •  再見小時候
    2020-12-19 11:56

    Actually, the result of your code is:

    [1, 4, 2289813904]

    But in case of squaring negative numbers you need to put the negative number in parenthesis:

    >>> (-10) ** 2
    

提交回复
热议问题