Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'value,': 0.04; 'say,': 0.05; 'subject:Python': 0.06; '64-bit': 0.07; 'float': 0.07; '22,': 0.09; '32-bit': 0.09; 'badly': 0.09; 'integers': 0.09; 'latter': 0.09; 'subject:Why': 0.09; 'terms,': 0.09; 'throws': 0.09; 'works.': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'thread': 0.14; "wouldn't": 0.14; 'bit).': 0.16; 'choice).': 0.16; 'display,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'integers,': 0.16; 'integers.': 0.16; "languages'": 0.16; 'roy': 0.16; 'discussions': 0.16; 'wrote:': 0.18; '(but': 0.19; 'cc:addr:python.org': 0.22; 'load': 0.23; 'integer': 0.24; 'subject:like': 0.24; 'fine': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'tim': 0.29; 'dec': 0.30; 'relative': 0.30; 'message-id:@mail.gmail.com': 0.30; 'asked': 0.31; 'asks': 0.31; 'chase': 0.31; 'dropped': 0.31; "they'll": 0.31; 'another': 0.32; 'quite': 0.32; '(including': 0.33; 'sense': 0.34; 'basic': 0.35; 'offered': 0.35; 'something': 0.35; 'no,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'accuracy': 0.36; 'doing': 0.36; 'possible': 0.36; 'performance': 0.37; 'starting': 0.37; 'represent': 0.38; 'depends': 0.38; 'support,': 0.39; 'space': 0.40; 'easy': 0.60; 'truly': 0.60; 'most': 0.60; 'new': 0.61; 'numbers': 0.61; 'range': 0.61; "you're": 0.61; 'first': 0.61; 'offer': 0.62; 'offering': 0.63; 'more': 0.64; 'nobody': 0.68; 'smith': 0.68; 'default': 0.69; '500': 0.70; 'article': 0.77; '100': 0.79; 'ridiculously': 0.84; 'to:none': 0.92; 'this!': 0.93; '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:cc :content-type; bh=S84rQzInuJHvEuTQPDdb6AjJUcEG1tvMy6DoUcO5dbY=; b=U5NgyxO39QmitKsfW03o8CkUShcuT0fcdRrCerBuwXHyJjP0GFkRQfdIS7Ms5vacVZ PUz2tckXhC2jT9UOC/4f1aAMIoIzuH61vcTgRZtuVpItWXUkMGoBN7ePfSVmehU64YTr R9sgHDi+vXwwfibv/BfYPgy7gPyHDU4wMWFoBFcY3PoygmOBLjJbSBk6aXXNQEL7vnry uDHpnU402GlXYVufbNIrq6Meg0NRMAq3oBa6nROFnxUfCTt1GRpXdkgg/uIhItDxRS/t X3MyucvzsUYPmO6lBT+WPLiqj0SaXSmSF41LWQL2p2g12sexNzgK3yAPW7cxYsDUbMWW SaPA== MIME-Version: 1.0 X-Received: by 10.66.102.39 with SMTP id fl7mr16177274pab.43.1387652644388; Sat, 21 Dec 2013 11:04:04 -0800 (PST) In-Reply-To: References: Date: Sun, 22 Dec 2013 06:04:04 +1100 Subject: Re: Why Python is like C++ From: Chris Angelico Cc: "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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 43 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1387652653 news.xs4all.nl 2892 [2001:888:2000:d::a6]:47229 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:62506 On Sun, Dec 22, 2013 at 2:59 AM, Roy Smith wrote: > In article , > Tim Chase wrote: > >> In know that my first BASIC, Applesoft BASIC had the 2-character >> names, and you had to load Integer Basic (with Ints in addition to the >> standard Floats used in the BASIC provided by the ROM, a strange >> choice). > > Why is it a strange choice? If you're only going to support a single > type of numeric value, floats make a lot more sense than ints. Floats > are a superset of integers. No, reals are a superset of integers, and are also a superset of floats. Whether a float can precisely represent every int in your pool depends on their relative sizes; in another thread we've just had complaints about fixed-size integers in C, but they do simplify discussions like this! With IEEE floating point, it's theoretically possible to represent any integer smaller than 2**M, where M is the size of the mantissa (including its leading 1 bit). In practical terms, that means your float has to take up twice as much space as an int would (a 64-bit float has a 53-bit mantissa, so it can represent 32-bit numbers - nobody actually asks for 53-bit integer support, but you do have it). I don't know about non-IEEE float systems, but they'll be doing something similar. Arbitrary precision throws a whole new spanner in the works. It's pretty easy to offer an arbitrary-precision integer type that guarantees accuracy down to the last digit. Offering a float type that can represent a ridiculous range of integers is problematic. I notice that Python offers the former and not the latter :) REXX offered configurable-precision numeric calculations, but performance dropped off badly as the precision rose. That is to say, it was fine for the default 9 digits, fine for 100 digits (but now you have to format numbers for display, or they'll be ugly), starting to get slow if you asked for 500 digits, and really quite ridiculously slow with NUMERIC DIGITS 10000. I wouldn't say that most languages' float type is truly a superset of int. ChrisA