Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Python comparing float
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Russell Jones  
View profile  
 More options Aug 28 2012, 3:26 pm
From: Russell Jones <russell.jo...@gmail.com>
Date: Tue, 28 Aug 2012 20:25:58 +0100
Local: Tues, Aug 28 2012 3:25 pm
Subject: Re: [pygame] Python comparing float

Alternatively, in the numpy module (part of the Scientific Tools for Python
http://www.scipy.org/ ) there is the linspace function, which you could use
like this
for x in numpy.linspace(0,2,21):
    print(x)

Russell

On 23 August 2012 14:34, Ricardo Franco <ricardo.kr...@gmail.com> wrote:

> Well, this is a good idea, I go do this way. tks

> 2012/8/22 Greg Ewing <greg.ew...@canterbury.ac.nz>

>> Ricardo Franco wrote:

>>>     That's why when you are comparing floating point numbers, you always
>>>     have to check if they are within some small error value from each
>>>     other. How large that value is depends on your particular use case.

>> It's even better if you can avoid comparing floats for
>> equality at all. You can do that in this case by using an
>> integer loop counter and computing the float value from it:

>> >>> for i in xrange(11):
>> ...    rate = 1.0 + i * 0.1
>> ...    print rate
>> ...
>> 1.0
>> 1.1
>> 1.2
>> 1.3
>> 1.4
>> 1.5
>> 1.6
>> 1.7
>> 1.8
>> 1.9
>> 2.0

>> --
>> Greg

> --
> Ricardo Franco Andrade             @ricardokrieg

> ( Game | Desktop | Web ) Developer

> email: ricardo.kr...@gmail.com
> contact: +55 (86) 9958 9725
>              +55 (86) 9436 0830
> twitter: twitter.com/ricardokrieg
> facebooK: https://www.facebook.com/krieg.ricardo
> github: https://github.com/ricardokrieg


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.