Python multiplication question.

Asked 2 years ago, Updated 2 years ago, 41 views

import numpy as np

r_a = np.arange(500, 50000, 500) # m

r_b = np.arange(150, 15000, 150) # m

a = 3*r_a + r_b

b = r_a + 3*r_b

a * b

When I ran the code above, I thought it was a structure that couldn't produce a negative number, but the result came out like this,

array([    1567500,     6270000,    14107500,    25080000,    39187500,
          56430000,    76807500,   100320000,   126967500,   156750000,
         189667500,   225720000,   264907500,   307230000,   352687500,
         401280000,   453007500,   507870000,   565867500,   627000000,
         691267500,   758670000,   829207500,   902880000,   979687500,
        1059630000,  1142707500,  1228920000,  1318267500,  1410750000,
        1506367500,  1605120000,  1707007500,  1812030000,  1920187500,
        2031480000,  2145907500, -2031497296, -1910799796, -1786967296,
       -1659999796, -1529897296, -1396659796, -1260287296, -1120779796,
        -978137296,  -832359796,  -683447296,  -531399796,  -376217296,
        -217899796,   -56447296,   108140204,   275862704,   446720204,
         620712704,   797840204,   978102704,  1161500204,  1348032704,
        1537700204,  1730502704,  1926440204,  2125512704, -1967247092,
       -1761904592, -1553427092, -1341814592, -1127067092,  -909184592,
        -688167092,  -464014592,  -236727092,    -6304592,   227252908,
         463945408,   703772908,   946735408,  1192832908,  1442065408,
        1694432908,  1949935408, -2086394388, -1824621888, -1559714388,
       -1291671888, -1020494388,  -746181888,  -468734388,  -188151888,
          95565612,   382418112,   672405612,   965528112,  1261785612,
        1561178112,  1863705612, -2125599184, -1816801684])

I also sent it to Google Collaboration just in case, but it works normally.

I don't know what the problem is. I don't know... Does anyone know?

numpy

2022-09-22 13:06

1 Answers

Considering the combination of the fact that it works in the Collaboration and the fact that there is no code problem, I think your interpreter does not support BIG INTEGER and uses 4Byte INTEGER. The absolute value of the number does not appear to exceed 232

32


2022-09-22 13:06

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.