Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: Random832 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: References: Mime-Version: 1.0 Content-Type: text/plain X-Trace: news.uni-berlin.de 4Jo07Mbic5KxkDh8hRb81gDxuBRQgI3sPdHfH8gqShFA== Cancel-Lock: sha1:MMa7u6cEScBDyBRvdtKLWFATJDw= Return-Path: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:101993 Terry Reedy 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.