python 3 long ints and multiplication

后端 未结 2 1216
醉话见心
醉话见心 2021-01-19 03:36

I\'m trying to execute next code int((226553150 * 1023473145) / 5) and python3 gives me an answer 46374212988031352. But ruby and swift give me an

2条回答
  •  南方客
    南方客 (楼主)
    2021-01-19 04:05

    You are missing that Python's division (from Python 3 on) is by default a float division, so you have reduced precision in that. Force the integer division by using // instead of / and you will get the same result.

提交回复
热议问题