Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #101948 > unrolled thread

Re: How to simulate C style integer division?

Started byYann Kaiser <kaiser.yann@gmail.com>
First post2016-01-21 08:42 +0000
Last post2016-01-21 08:42 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: How to simulate C style integer division? Yann Kaiser <kaiser.yann@gmail.com> - 2016-01-21 08:42 +0000

#101948 — Re: How to simulate C style integer division?

FromYann Kaiser <kaiser.yann@gmail.com>
Date2016-01-21 08:42 +0000
SubjectRe: How to simulate C style integer division?
Message-ID<mailman.141.1453365734.15297.python-list@python.org>
You can use the // operator, which should do what you want.

On Thu, Jan 21, 2016, 09:40 Shiyao Ma <i@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
>

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web