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


Groups > comp.lang.python > #20795

Re: subtraction of floating point numbers

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <chris@rebertia.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.013
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'example:': 0.03; 'python': 0.08; 'am,': 0.12; 'subtract': 0.16; 'cc:addr:python-list': 0.16; 'this:': 0.16; 'wrote:': 0.18; 'cc:no real name:2**0': 0.21; "doesn't": 0.22; 'header:In-Reply-To:1': 0.22; 'feb': 0.22; 'subject:numbers': 0.23; 'received:209.85.220': 0.25; 'cc:2**0': 0.26; 'message-id:@mail.gmail.com': 0.29; '24,': 0.29; 'weird': 0.29; 'yield': 0.29; 'problem': 0.29; 'cc:addr:python.org': 0.29; 'correct': 0.29; 'yields': 0.30; 'chris': 0.30; 'thread': 0.32; 'fri,': 0.34; 'url:python': 0.35; 'url:pipermail': 0.37; 'hello,': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.38; 'some': 0.38; 'url:org': 0.39; 'received:209': 0.39; 'point': 0.40; 'header:Received:6': 0.61; 'sender:addr:chris': 0.84
Received-SPF pass (google.com: domain of chris@rebertia.com designates 10.52.173.79 as permitted sender) client-ip=10.52.173.79;
Authentication-Results mr.google.com; spf=pass (google.com: domain of chris@rebertia.com designates 10.52.173.79 as permitted sender) smtp.mail=chris@rebertia.com; dkim=pass header.i=chris@rebertia.com
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=GprgZza8bYkRymAkj6vAa6CczaJm/T/h90YX4YLPCB4=; b=CymQRIJtuBynfFSQSj+kheJQn35BkLdEpHFpSm/8zYb97L0UfPQlP9+8GMBNkLQsia Gqi66DsYPheNxp/2tGFLYpeRGxsAXtCclmhhGhoCFM+aS0fgDcjvzF17gAxW/KSPvxyS rhDhJ6iULZS4eewQUJandgpe2qDTDSXd9J3gQ=
MIME-Version 1.0
Sender chris@rebertia.com
In-Reply-To <a4dbc794-db02-4cc4-a22a-cf64c91bbb50@v2g2000vbx.googlegroups.com>
References <a4dbc794-db02-4cc4-a22a-cf64c91bbb50@v2g2000vbx.googlegroups.com>
Date Fri, 24 Feb 2012 02:16:29 -0800
X-Google-Sender-Auth GQtoCYN0VOdGraylB5uewspibXg
Subject Re: subtraction of floating point numbers
From Chris Rebert <clp2@rebertia.com>
To Jaroslav Dobrek <jaroslav.dobrek@gmail.com>
Content-Type text/plain; charset=UTF-8
X-Gm-Message-State ALoCoQn+CQ26C9hcM1ZOBUwo6rouCyiwpnb0NMSto+mokMkWXAeFxs25YXl1hdGnxyznOitYLCZI
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
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.119.1330078592.3037.python-list@python.org> (permalink)
Lines 21
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1330078592 news.xs4all.nl 6908 [2001:888:2000:d::a6]:42137
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:20795

Show key headers only | View raw


On Fri, Feb 24, 2012 at 12:41 AM, Jaroslav Dobrek
<jaroslav.dobrek@gmail.com> wrote:
> Hello,
>
> when I have Python subtract floating point numbers it yields weird
> results. Example:
>
> 4822.40 - 4785.52 = 36.8799999999992
>
> Why doesn't Python simply yield the correct result? It doesn't have a
> problem with this:
>
> 482240 - 478552 = 3688
>
> Can I tell Python in some way to do this differently?

Refer to this thread from 2 days ago:
http://mail.python.org/pipermail/python-list/2012-February/1288344.html

Regards,
Chris

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


Thread

subtraction of floating point numbers Jaroslav Dobrek <jaroslav.dobrek@gmail.com> - 2012-02-24 00:41 -0800
  Re: subtraction of floating point numbers Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2012-02-24 09:49 +0100
  Re: subtraction of floating point numbers Chris Rebert <clp2@rebertia.com> - 2012-02-24 02:16 -0800

csiph-web