Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #51455
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.datemas.de!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.054 |
| X-Spam-Evidence | '*H*': 0.89; '*S*': 0.00; 'mrab': 0.05; 'float': 0.07; 'constructor.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'rounding': 0.16; 'wrote:': 0.18; 'library': 0.18; 'all,': 0.19; '>>>': 0.22; 'fraction': 0.24; 'mon,': 0.24; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'function': 0.29; 'cool': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'but': 0.35; 'received:google.com': 0.35; 'should': 0.36; 'list': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'little': 0.38; 'to:addr:python.org': 0.39; 'ago,': 0.61; 'mentioned': 0.61; 'become': 0.64; 'more': 0.64; 'jul': 0.74; 'subject:results': 0.91; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=T0Xls7PBV1OfX93i4YlviojgpEe2L96r6gH3BIlQAEY=; b=HAl+8zNLasFdp/tbcb5evh0PIAh9pKn8BuPE3xQLrnP3x0ai1YPRLwQr6NSPs6CeGV nD4YMDAZtf7eqO3Dv3WKugqe2e0ZrKIHtgs9YySkXLHwlnFjClVAyqJpzMvcE1nBtnZb Ti/ZaQqknN6CfDtA0J4UE/2KwGCFbwlKVrp1UEhbprr8snGbQJg7CFSghr0KNoFZVNF8 /oLVUhz6SiNoi4Xvw1ht4H22ZPo3jc2YIsSYSud+hiXxolvzT5HcDr2Av02Qf8iGlWsu zoTU+cakMYjuCQExfF3YM0bMOLBQ9IYXsVeaGEU7vS+MBa/b6Tfvc12QvyRuEPEMHbVs XXiQ== |
| MIME-Version | 1.0 |
| X-Received | by 10.52.34.40 with SMTP id w8mr21667282vdi.7.1375114827130; Mon, 29 Jul 2013 09:20:27 -0700 (PDT) |
| In-Reply-To | <51F693B4.9000201@mrabarnett.plus.com> |
| References | <51f68d9c$0$30000$c3e8da3$5496439d@news.astraweb.com> <51F693B4.9000201@mrabarnett.plus.com> |
| Date | Mon, 29 Jul 2013 17:20:27 +0100 |
| Subject | Re: Unexpected results comparing float to Fraction |
| From | Chris Angelico <rosuav@gmail.com> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5240.1375115193.3114.python-list@python.org> (permalink) |
| Lines | 27 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1375115193 news.xs4all.nl 15941 [2001:888:2000:d::a6]:59604 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:51455 |
Show key headers only | View raw
On Mon, Jul 29, 2013 at 5:09 PM, MRAB <python@mrabarnett.plus.com> wrote: > I'm surprised that Fraction(1/3) != Fraction(1, 3); after all, floats > are approximate anyway, and the float value 1/3 is more likely to be > Fraction(1, 3) than Fraction(6004799503160661, 18014398509481984). At what point should it become Fraction(1, 3)? >>> Fraction(0.3) Fraction(5404319552844595, 18014398509481984) >>> Fraction(0.33) Fraction(5944751508129055, 18014398509481984) >>> Fraction(0.333) Fraction(5998794703657501, 18014398509481984) >>> Fraction(0.3333333) Fraction(6004798902680711, 18014398509481984) >>> Fraction(0.3333333333) Fraction(6004799502560181, 18014398509481984) >>> Fraction(0.3333333333333) Fraction(6004799503160061, 18014398509481984) >>> Fraction(0.33333333333333333) Fraction(6004799503160661, 18014398509481984) Rounding off like that is a job for a cool library function (one of which was mentioned on this list a little while ago, I believe), but not IMO for the Fraction constructor. ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Unexpected results comparing float to Fraction Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-29 15:43 +0000
Re: Unexpected results comparing float to Fraction Ian Kelly <ian.g.kelly@gmail.com> - 2013-07-29 09:50 -0600
Re: Unexpected results comparing float to Fraction MRAB <python@mrabarnett.plus.com> - 2013-07-29 17:09 +0100
Re: Unexpected results comparing float to Fraction Chris Angelico <rosuav@gmail.com> - 2013-07-29 17:20 +0100
Re: Unexpected results comparing float to Fraction Rotwang <sg552@hotmail.co.uk> - 2013-07-29 19:20 +0100
Re: Unexpected results comparing float to Fraction Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-29 19:32 +0000
Re: Unexpected results comparing float to Fraction MRAB <python@mrabarnett.plus.com> - 2013-07-29 17:48 +0100
Re: Unexpected results comparing float to Fraction Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-29 17:27 +0000
Re: Unexpected results comparing float to Fraction Ian Kelly <ian.g.kelly@gmail.com> - 2013-07-29 10:40 -0600
Re: Unexpected results comparing float to Fraction Rotwang <sg552@hotmail.co.uk> - 2013-07-29 19:16 +0100
Re: Unexpected results comparing float to Fraction Ian Kelly <ian.g.kelly@gmail.com> - 2013-07-29 13:33 -0600
Re: Unexpected results comparing float to Fraction MRAB <python@mrabarnett.plus.com> - 2013-07-29 18:04 +0100
Re: Unexpected results comparing float to Fraction Grant Edwards <invalid@invalid.invalid> - 2013-07-29 18:46 +0000
Re: Unexpected results comparing float to Fraction Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-29 20:19 +0000
Re: Unexpected results comparing float to Fraction Terry Reedy <tjreedy@udel.edu> - 2013-07-29 13:08 -0400
Re: Unexpected results comparing float to Fraction Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-29 17:29 +0000
Re: Unexpected results comparing float to Fraction Terry Reedy <tjreedy@udel.edu> - 2013-07-29 16:48 -0400
Re: Unexpected results comparing float to Fraction Chris Angelico <rosuav@gmail.com> - 2013-07-29 18:14 +0100
Re: Unexpected results comparing float to Fraction Ian Kelly <ian.g.kelly@gmail.com> - 2013-07-29 11:35 -0600
Re: Unexpected results comparing float to Fraction Serhiy Storchaka <storchaka@gmail.com> - 2013-07-29 22:34 +0300
Re: Unexpected results comparing float to Fraction Ian Kelly <ian.g.kelly@gmail.com> - 2013-07-29 14:35 -0600
Unexpected results comparing float to Fraction Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-07-30 14:32 +0100
Re: Unexpected results comparing float to Fraction Tony the Tiger <tony@tiger.invalid> - 2013-07-31 15:23 -0500
Re: Unexpected results comparing float to Fraction Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-01 06:20 +0000
Re: Unexpected results comparing float to Fraction Chris Angelico <rosuav@gmail.com> - 2013-08-01 07:32 +0100
Re: Unexpected results comparing float to Fraction Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-08-01 10:44 +0100
Re: Unexpected results comparing float to Fraction Chris Angelico <rosuav@gmail.com> - 2013-08-01 10:48 +0100
csiph-web