Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #101948
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Yann Kaiser <kaiser.yann@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: How to simulate C style integer division? |
| Date | Thu, 21 Jan 2016 08:42:02 +0000 |
| Lines | 29 |
| Message-ID | <mailman.141.1453365734.15297.python-list@python.org> (permalink) |
| References | <CAJQX3DyoDUtNWbNEpGVJxeKATADWAikP47NRZb7+UaxSwSRZaQ@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| X-Trace | news.uni-berlin.de 8SFLj2XcDG1GZHFEFoO95QA+bhD4kLtevRQAgqD1dX5w== |
| Return-Path | <kaiser.yann@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'else:': 0.03; '21,': 0.07; 'subject:How': 0.09; 'operator,': 0.09; 'jan': 0.11; 'received:74.125.82.44': 0.15; 'thu,': 0.15; 'python3.': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'simulate': 0.16; 'wrote:': 0.16; 'integer': 0.18; '>': 0.18; 'math': 0.20; 'to:2**1': 0.21; 'import': 0.24; 'header:In-Reply-To:1': 0.24; "i've": 0.25; 'message-id:@mail.gmail.com': 0.27; 'division': 0.29; 'way?': 0.29; 'url:mailman': 0.30; 'url:python': 0.33; 'url:listinfo': 0.34; 'received:google.com': 0.35; 'received:74.125.82': 0.35; 'too': 0.36; 'should': 0.36; 'url:org': 0.36; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'hi,': 0.38; 'url:mail': 0.40; 'to:addr:python.org': 0.40; 'url:me': 0.64; '8bit%:100': 0.70; 'skip:\xe5 40': 0.84; 'to:name:python': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-type; bh=jrW6W01lOEEUNJluhx+blokBkIX6a3tteZr4rGLKfhg=; b=ivrKDVZAgpfJWoOtGK8YgAS/nyYyvY6IhPJFcJacgaZpZzsKhWtQZNKJcec9f0kkcM fr1JAO+5EX+hK7mA6xZl385FZpkkxpwB56WhTkf5NBVNafbVCz3+ItFput1LinatFQwr YdKomU7MDmoGzqghCSKeqAmFtPy/NOys1e+NRuytESXhR3k3LBbiOmaikDBnv4IyJLo4 CcepulpMSLI3hH4OwNC/cTlt8+iSL77EmXHOnM7UNgVnaFJXj0669kxGlQfrbm1oyF2H TSAqpBLC7ACI406t0TPLI+c95R7BxkOL10aKSzcTPIOPMgrAvkSwC9Ch+Y3cSmg1+Tgg ocWw== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:content-type; bh=jrW6W01lOEEUNJluhx+blokBkIX6a3tteZr4rGLKfhg=; b=IiG+EH3Wty6P5oMfXVqamBCrJmEbqaYYBgEVl/Liy7UqGXptyMAS9Exh6HhtHd+e7k R1O+pqYS+52D4f0l4eO7WKLreyWx4bDwBCijPLKIw9/V/jguWZUWbN5VuazgH6uZoUiz LeyQL+SXwtlr6hRpa8ciuhWxgO1E05qRsq2V6yvxmHqf7RgKBS1MIZ4WSBHNsA6GN4XI xXRR511T4F6iS/HvYWFQ4fD3GkgXpL9VFfHpaRpHC/IqJh/Fd47n5GUKpKsos7RTsouv MvgDDAIchnhmejfOiqTePj87JM7XxQ8NS7Fml6vIewnjExBGKK6bdQZhPbAvzTO36yzt gEhg== |
| X-Gm-Message-State | AG10YOT45j4EHaWXcwHap5XYtBiinbEgh1c1oXgbLQTO+VFJ+h/mn/4qsDaV5T8Vr7wTxJB6n29LDijjzVGG/Q== |
| X-Received | by 10.194.6.165 with SMTP id c5mr28919005wja.88.1453365732267; Thu, 21 Jan 2016 00:42:12 -0800 (PST) |
| In-Reply-To | <CAJQX3DyoDUtNWbNEpGVJxeKATADWAikP47NRZb7+UaxSwSRZaQ@mail.gmail.com> |
| X-Content-Filtered-By | Mailman/MimeDel 2.1.20+ |
| 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:101948 |
Show key headers only | View raw
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 >
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: How to simulate C style integer division? Yann Kaiser <kaiser.yann@gmail.com> - 2016-01-21 08:42 +0000
csiph-web