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


Groups > comp.lang.python > #66403

Re: decimal numbers

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!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.009
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'float': 0.07; 'python3': 0.07; 'cc:addr:python-list': 0.11; '__future__': 0.16; 'directive': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'reproduce': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'feb': 0.22; '>>>': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; 'integer': 0.24; 'cc:2**0': 0.24; '15,': 0.26; 'header:In- Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; '>>>>': 0.31; 'division': 0.31; 'subject:numbers': 0.31; 'received:google.com': 0.35; 'pm,': 0.38; 'changed': 0.39; 'frank': 0.68; 'divided': 0.91; 'to:none': 0.92
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:cc :content-type; bh=QNUkxL3Dc3A6YaUStTK7YA/KZcFOrBUEE5woMsuQW8w=; b=Ph+2HeZC+/9tkDnXFSB3836r0ETo5AGyLUpGzWSyCnu+oL8dpaakLnOlxQY9Xgo551 CoQx8T3UC/4toLBhafbluwCLSdzrtUgzGZ/2ojSkavJ2eYBhhmXd2ReCAMqa+3qJw2av S2IHjcTbrfDUcSrAJ0Nyki/HUgIvbTRpSxMhEHBJQVDXWnmxFzTlsUAI9IzcQVPUhiN2 Alb1V7E+Dmqr9gGoe4fy84+EpLmoPTRHWBNfqrJf2cI/XSYp2cwx5eCAEOPcFNzh2G8X dYXK5nyUrnyw9pjLM9vwLt4t16si1DoJohBTfxrEJaIOCD96RC0YawdHy0it6QxwozaN uvUA==
MIME-Version 1.0
X-Received by 10.68.162.66 with SMTP id xy2mr14621771pbb.46.1392459200488; Sat, 15 Feb 2014 02:13:20 -0800 (PST)
In-Reply-To <ldne2i$hl8$1@ger.gmane.org>
References <833583c7-c307-4ebf-9a60-3be146a565b5@googlegroups.com> <ec88852e-1384-4aa5-834b-85135be94ab9@googlegroups.com> <ldne2i$hl8$1@ger.gmane.org>
Date Sat, 15 Feb 2014 21:13:20 +1100
Subject Re: decimal numbers
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
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 <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>
Newsgroups comp.lang.python
Message-ID <mailman.6977.1392459209.18130.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1392459209 news.xs4all.nl 2895 [2001:888:2000:d::a6]:44728
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:66403

Show key headers only | View raw


On Sat, Feb 15, 2014 at 9:04 PM, Frank Millman <frank@chagford.com> wrote:
> If you are using python2, an integer divided by an integer always returns an
> integer -
>
>>>> 10/3
> 3
>
> It was changed in python3 to return a float -
>
>>>> 10/3
> 3.3333333333333335
>
> You can reproduce the python3 behaviour in python2 by adding a 'future'
> directive -
>
>>>> from __future__ import division
>>>> 10/3
> 3.3333333333333335
>

Conversely, you can get an integer result by using floor division:

>>> 10//3
3

ChrisA

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


Thread

decimal numbers luke.geelen@gmail.com - 2014-02-15 01:18 -0800
  Re: decimal numbers Luke Geelen <luke.geelen@gmail.com> - 2014-02-15 01:19 -0800
    Re: decimal numbers "Frank Millman" <frank@chagford.com> - 2014-02-15 12:04 +0200
      Re: decimal numbers Luke Geelen <luke.geelen@gmail.com> - 2014-02-15 02:32 -0800
        Re: decimal numbers "Frank Millman" <frank@chagford.com> - 2014-02-15 12:49 +0200
          Re: decimal numbers Luke Geelen <luke.geelen@gmail.com> - 2014-02-15 09:17 -0800
            Re: decimal numbers Ian Kelly <ian.g.kelly@gmail.com> - 2014-02-15 10:23 -0700
              Re: decimal numbers Luke Geelen <luke.geelen@gmail.com> - 2014-02-15 09:42 -0800
                Re: decimal numbers Luke Geelen <luke.geelen@gmail.com> - 2014-02-15 10:57 -0800
                Re: decimal numbers Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-15 19:06 +0000
                Re: decimal numbers Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-15 19:43 +0000
                Re: decimal numbers Ian Kelly <ian.g.kelly@gmail.com> - 2014-02-15 14:34 -0700
                Re: decimal numbers Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-16 02:30 +0000
                Re: decimal numbers Chris Angelico <rosuav@gmail.com> - 2014-02-16 13:36 +1100
        Re: decimal numbers "Frank Millman" <frank@chagford.com> - 2014-02-15 12:56 +0200
    Re: decimal numbers Chris Angelico <rosuav@gmail.com> - 2014-02-15 21:13 +1100
  Re: decimal numbers Laurent Pointal <laurent.pointal@free.fr> - 2014-02-15 15:52 +0100
  Re: decimal numbers Ian Kelly <ian.g.kelly@gmail.com> - 2014-02-15 10:20 -0700
  Re: decimal numbers wxjmfauth@gmail.com - 2014-02-16 04:19 -0800

csiph-web