Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #101949
| Path | csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | "Peter Heitzer" <peter.heitzer@rz.uni-regensburg.de> |
| Newsgroups | comp.lang.python |
| Subject | Re: How to simulate C style integer division? |
| Date | 21 Jan 2016 08:44:38 GMT |
| Lines | 23 |
| Message-ID | <dgbk3mF6045U1@mid.individual.net> (permalink) |
| References | <mailman.139.1453365561.15297.python-list@python.org> |
| X-Trace | individual.net yEfJAZHmLBoaFDb0/SffyQFkDrtsKAViE5RsMd9cqHxBt+EFth4RgG8UCb |
| X-Orig-Path | not-for-mail |
| Cancel-Lock | sha1:Z/Dg8dGyBIEIwk7yVxOhZY+qDNg= |
| User-Agent | tin/2.2.1-20140504 ("Tober an Righ") (UNIX) (Linux/3.16.0-4-amd64 (x86_64)) |
| Xref | csiph.com comp.lang.python:101949 |
Show key headers only | View raw
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? In Python3 you have to use the floor division operator '//' For example: result=a//b
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to simulate C style integer division? Shiyao Ma <i@introo.me> - 2016-01-21 16:39 +0800
Re: How to simulate C style integer division? "Peter Heitzer" <peter.heitzer@rz.uni-regensburg.de> - 2016-01-21 08:44 +0000
Re: How to simulate C style integer division? Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-01-21 10:59 +0200
Re: How to simulate C style integer division? Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-01-21 12:13 +0200
Re: How to simulate C style integer division? Grobu <snailcoder@retrosite.invalid> - 2016-01-22 02:59 +0100
Re: How to simulate C style integer division? Steven D'Aprano <steve@pearwood.info> - 2016-01-22 14:48 +1100
Re: How to simulate C style integer division? Grobu <snailcoder@retrosite.invalid> - 2016-01-23 13:04 +0100
Re: How to simulate C style integer division? Grobu <snailcoder@retrosite.invalid> - 2016-01-23 13:52 +0100
Re: How to simulate C style integer division? Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-01-23 17:07 +0200
Re: How to simulate C style integer division? Grobu <snailcoder@retrosite.invalid> - 2016-01-23 17:44 +0100
csiph-web