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


Groups > comp.lang.python > #38084

Re: Floating point calculation problem

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nntp-feed.chiark.greenend.org.uk!ewrotcd!feeds.news.ox.ac.uk!news.ox.ac.uk!zen.net.uk!hamilton.zen.co.uk!xlned.com!feeder3.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <torriem@gmail.com>
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; 'method.': 0.05; 'classes.': 0.07; 'implements': 0.07; 'method,': 0.07; 'referring': 0.07; 'def': 0.10; 'language': 0.14; 'properly': 0.15; 'coercion.': 0.16; 'from:addr:torriem': 0.16; 'from:name:michael torrie': 0.16; 'wanted.': 0.16; 'wrote:': 0.17; 'refers': 0.17; 'typing': 0.17; 'subject:problem': 0.22; 'this:': 0.23; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; 'implemented': 0.27; 'interface': 0.27; 'necessary,': 0.29; 'function': 0.30; 'could': 0.32; 'to:addr:python-list': 0.33; 'another': 0.33; 'add': 0.36; 'received:org': 0.36; 'but': 0.36; 'message-id:@gmail.com': 0.36; 'depends': 0.36; 'method': 0.36; 'does': 0.37; 'subject:: ': 0.38; 'fact': 0.38; 'object': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'where': 0.40; 'received:192.168': 0.40; 'header:Received:5': 0.40; 'cast': 0.65
X-Virus-Scanned amavisd-new at torriefamily.org
Date Sat, 02 Feb 2013 11:19:41 -0700
From Michael Torrie <torriem@gmail.com>
User-Agent Mozilla/5.0 (X11; Linux i686; rv:10.0.12) Gecko/20130105 Thunderbird/10.0.12
MIME-Version 1.0
To python-list@python.org
Subject Re: Floating point calculation problem
References <keipl5$kif$1@dont-email.me><mailman.1289.1359801291.2939.python-list@python.org><keisev$7v1$1@dont-email.me><mailman.1291.1359804020.2939.python-list@python.org><keitk2$hln$1@dont-email.me><mailman.1292.1359805138.2939.python-list@python.org><keiujd$o71$1@dont-email.me> <mailman.1293.1359806334.2939.python-list@python.org> <kejcfi$s70$1@dont-email.me>
In-Reply-To <kejcfi$s70$1@dont-email.me>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
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.1298.1359829190.2939.python-list@python.org> (permalink)
Lines 30
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1359829190 news.xs4all.nl 6866 [2001:888:2000:d::a6]:60401
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:38084

Show key headers only | View raw


On 02/02/2013 08:48 AM, Schizoid Man wrote:
> Also, if the cast is necessary, then now exactly does the dynamic typing 
> work?

Dynamic typing isn't referring to numeric type coercion.  It refers to
the fact that a name can be bound to an object of any type.  So if you
made a function like this:

def add (num1, num2):
    return num1 + num2

num1 and num2 could be any type.  Even a custom type if you wanted.
This function would work properly on any type that had implemented the
__add__ method.  And whether or not num2 has to be the same type as num1
depends on whether the num1 type has implemented an __add__ method that
can deal with the type of num2.

Another case where dynamic typing comes into play is in a case know as
duck typing:

def squeeze_duck (duck):
	// return the quack
	return duck.squeeze()


duck can be of any type as well, but as long as it implements the
squeeze method, this function will work with an object of that type.

In a language like C#, duck-typing can only be emulated by using
interface classes.

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


Thread

Floating point calculation problem "Schizoid Man" <schiz_man@21stcentury.com> - 2013-02-02 10:27 +0000
  Re: Floating point calculation problem Chris Angelico <rosuav@gmail.com> - 2013-02-02 21:34 +1100
    Re: Floating point calculation problem "Schizoid Man" <schiz_man@21stcentury.com> - 2013-02-02 11:14 +0000
      Re: Floating point calculation problem Chris Angelico <rosuav@gmail.com> - 2013-02-02 22:20 +1100
        Re: Floating point calculation problem "Schizoid Man" <schiz_man@21stcentury.com> - 2013-02-02 11:34 +0000
          Re: Floating point calculation problem Chris Angelico <rosuav@gmail.com> - 2013-02-02 22:38 +1100
            Re: Floating point calculation problem "Schizoid Man" <schiz_man@21stcentury.com> - 2013-02-02 11:51 +0000
              Re: Floating point calculation problem Chris Angelico <rosuav@gmail.com> - 2013-02-02 22:58 +1100
                Re: Floating point calculation problem "Schizoid Man" <schiz_man@21stcentury.com> - 2013-02-02 15:48 +0000
                Re: Floating point calculation problem "Schizoid Man" <schiz_man@21stcentury.com> - 2013-02-02 15:54 +0000
                Re: Floating point calculation problem Chris Angelico <rosuav@gmail.com> - 2013-02-03 03:00 +1100
                Re: Floating point calculation problem Michael Torrie <torriem@gmail.com> - 2013-02-02 11:19 -0700
                Re: Floating point calculation problem Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-03 12:25 +1100
                Re: Floating point calculation problem Dave Angel <d@davea.name> - 2013-02-02 21:20 -0500
                Re: Floating point calculation problem Michael Torrie <torriem@gmail.com> - 2013-02-02 21:22 -0700
              Re: Floating point calculation problem Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-02 23:11 +1100
      Re: Floating point calculation problem Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-02 22:45 +1100
        Re: Floating point calculation problem "Schizoid Man" <schiz_man@21stcentury.com> - 2013-02-02 11:50 +0000
  Re: Floating point calculation problem Chris Rebert <clp2@rebertia.com> - 2013-02-02 02:47 -0800
  Re: Floating point calculation problem Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-02 23:05 +1100

csiph-web