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


Groups > comp.lang.python > #101993

Re: How to simulate C style integer division?

Path csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From Random832 <random832@fastmail.com>
Newsgroups comp.lang.python
Subject Re: How to simulate C style integer division?
Date Fri, 22 Jan 2016 00:58:29 -0500
Lines 10
Message-ID <mailman.160.1453442317.15297.python-list@python.org> (permalink)
References <CAJQX3DyoDUtNWbNEpGVJxeKATADWAikP47NRZb7+UaxSwSRZaQ@mail.gmail.com> <n7s5oa$18c$1@ger.gmane.org> <n7s7jp$q7u$1@ger.gmane.org>
Mime-Version 1.0
Content-Type text/plain
X-Trace news.uni-berlin.de 4Jo07Mbic5KxkDh8hRb81gDxuBRQgI3sPdHfH8gqShFA==
Cancel-Lock sha1:MMa7u6cEScBDyBRvdtKLWFATJDw=
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'subject:How': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'spec': 0.09; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'reedy': 0.16; 'test.': 0.18; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'minimal': 0.30; 'point': 0.33; 'received:comcast.net': 0.33; 'true.': 0.33; 'clear': 0.35; 'but': 0.36; 'cases': 0.36; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'test': 0.39; 'to:addr:python.org': 0.40
X-Injected-Via-Gmane http://gmane.org/
X-Gmane-NNTP-Posting-Host c-68-39-146-59.hsd1.in.comcast.net
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/24.5 (darwin)
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:101993

Show key headers only | View raw


Terry Reedy <tjreedy@udel.edu> writes:
> But fails with remainder 0, as others noted.  Lesson: include corner
> cases in validation test.  Anyway, my main point about writing a clear
> spec remains true.

My validation test for this was to loop both numerator and denominator
from -5 to 5 (skipping denominator 0) to cover all cases (comparing
against the original post's unoptimized code) without having to think
about a minimal set to cover them.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: How to simulate C style integer division? Random832 <random832@fastmail.com> - 2016-01-22 00:58 -0500

csiph-web