How to simulate C style integer division?
Yann Kaiser
kaiser.yann at gmail.com
Thu Jan 21 03:42:02 EST 2016
You can use the // operator, which should do what you want.
On Thu, Jan 21, 2016, 09:40 Shiyao Ma <i at introo.me> wrote:
> Hi,
>
> I wanna simulate C style integer division in Python3.
>
> So far what I've got is:
> # a, b = 3, 4
>
> import math
> result = float(a) / b
> if result > 0:
> result = math.floor(result)
> else:
> result = math.ceil(result)
>
>
> I found it's too laborious. Any quick way?
>
> --
>
> 吾輩は猫である。ホームーページはhttps://introo.me <http://introo.me>。
> --
> https://mail.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list