Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #101987
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Matt Wheeler <m@funkyhat.org> |
| Newsgroups | comp.lang.python |
| Subject | Re: How to simulate C style integer division? |
| Date | Fri, 22 Jan 2016 00:51:21 +0000 |
| Lines | 27 |
| Message-ID | <mailman.156.1453424217.15297.python-list@python.org> (permalink) |
| References | <CAJQX3DyoDUtNWbNEpGVJxeKATADWAikP47NRZb7+UaxSwSRZaQ@mail.gmail.com> <mailman.143.1453367498.15297.python-list@python.org> <56a0d24f$0$1614$c3e8da3$5496439d@news.astraweb.com> <lf5mvrzuj5z.fsf@ling.helsinki.fi> <87mvrzc8bx.fsf@elektro.pacujo.net> <mailman.155.1453405932.15297.python-list@python.org> <877fj263aj.fsf@elektro.pacujo.net> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de k0m4TxAkMKSizWfSKA0/cAJ501mnjtii+jSnIPfNSONQ== |
| Return-Path | <m@funkyhat.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.006 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'cc:addr:python-list': 0.09; 'subject:How': 0.09; 'def': 0.13; '2016': 0.16; '21:17,': 0.16; 'b):': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'skip:1 40': 0.16; 'wrote:': 0.16; '>>>': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'cc:no real name:2**0': 0.22; 'header :In-Reply-To:1': 0.24; 'message-id:@mail.gmail.com': 0.27; 'skip:2 30': 0.29; 'received:google.com': 0.35; 'received:74.125.82': 0.35; 'depends': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'january': 0.38; 'from:addr:m': 0.84 |
| X-Virus-Scanned | Debian amavisd-new at membrane.funkyhat.net |
| X-Gm-Message-State | AG10YOQzhSxZBnbY7TWsEmUybiVfuauZGTNIxzVv8elNrnpLgwoel3sw8vYleF5Ab1AKZzMFr+YTl4tofKSBQw== |
| X-Received | by 10.28.130.205 with SMTP id e196mr524606wmd.34.1453423900958; Thu, 21 Jan 2016 16:51:40 -0800 (PST) |
| In-Reply-To | <877fj263aj.fsf@elektro.pacujo.net> |
| X-Gmail-Original-Message-ID | <CAG93HwGn4y8FhNCoy0N3LhvMAThV1aydeew6LjbB0256FfSczw@mail.gmail.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:101987 |
Show key headers only | View raw
On 21 January 2016 at 21:17, Marko Rauhamaa <marko@pacujo.net> wrote: > Well, then there's: > > def intdiv(a, b): > return int(a / b) That depends on how accurate you need it to be >>> def intdiv(a, b): ... return a//b if (a < 0) == (b < 0) else -(-a//b) ... >>> num = 3**171 >>> num 3870210234510307998744588107535211184800325224934979257430349324033792477926791547 >>> num2 = 4**80 >>> num2 1461501637330902918203684832716283019655932542976 >>> intdiv(num, num2) 2648105301871818722187687529062555 >>> int(num/num2) 2648105301871818477801931416797184 -- Matt Wheeler http://funkyh.at
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: How to simulate C style integer division? Ben Finney <ben+python@benfinney.id.au> - 2016-01-21 20:11 +1100
Re: How to simulate C style integer division? Paul Rubin <no.email@nospam.invalid> - 2016-01-21 01:43 -0800
Re: How to simulate C style integer division? Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-01-21 11:58 +0200
Re: How to simulate C style integer division? Steven D'Aprano <steve@pearwood.info> - 2016-01-21 23:42 +1100
Re: How to simulate C style integer division? Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-01-21 16:00 +0200
Re: How to simulate C style integer division? Marko Rauhamaa <marko@pacujo.net> - 2016-01-21 16:31 +0200
Re: How to simulate C style integer division? Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-01-21 16:48 +0200
Re: How to simulate C style integer division? Random832 <random832@fastmail.com> - 2016-01-21 14:52 -0500
Re: How to simulate C style integer division? Marko Rauhamaa <marko@pacujo.net> - 2016-01-21 23:17 +0200
Re: How to simulate C style integer division? Matt Wheeler <m@funkyhat.org> - 2016-01-22 00:51 +0000
Re: How to simulate C style integer division? Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2016-01-21 15:22 +0100
csiph-web