[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] Python comparing float
- To: pygame-users@xxxxxxxx
- Subject: [pygame] Python comparing float
- From: Ricardo Franco <ricardo.krieg@xxxxxxxxx>
- Date: Wed, 22 Aug 2012 16:07:40 -0300
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Wed, 22 Aug 2012 15:06:57 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=3dTITF3zKXNGDIQVzuRsK0s0SNgNnWtxBvFDlx93S0Y=; b=EdbK+DIvLvt3/SBAJ2B+FVdQJe6PaLCnL/TCECjf5EpUL+vPLrPXsZVj6oROiYUK9N 0p7WqoyLhDj3igqhgMb7k4MxA0rIHzbiTfvFZ32Vk57VE/sDS4YLWXMe+OBIkyGPbwox 5FSQIildpA+kenUN7sM2KEX+4LIb/yrOn9PnG4PcWvpWumF05ATvXMew/u0a7pxFY+6/ 5tBDqXPhvUM01t/idWIvELDCWhhdFFM1zqyFMXuewvvkr1souJwSwhfkIeq+hjgw8Kee ZGg8thzE9a113bff6TxWcQlMi9go0u0fV2Lg3KWhF+1EIHR6Ehr3o2mIgOc50I6FLMyw 8MAw==
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
Hi, this is more a question about python than pygame. Considering this code:
#####################################################
rate = 1
desired_rate = 2
while True:
if rate != desired_rate:
print rate, desired_rate, (rate != desired_rate)
rate += 0.1 * (1 if desired_rate > rate else -1)
# if
# while
#####################################################
It should smoothly move rate from 1 until 2.
But the output is this:
1 2 True
1.1 2 True
1.2 2 True
1.3 2 True
1.4 2 True
1.5 2 True
1.6 2 True
1.7 2 True
1.8 2 True
1.9 2 True
2.0 2 True
1.9 2 True
2.0 2 True
1.9 2 True
2.0 2 True
1.9 2 True
2.0 2 True
1.9 2 True
2.0 2 True
...
Is python missing in comparison?
--
Ricardo Franco Andrade @ricardokrieg
( Game | Desktop | Web ) Developer
email:
ricardo.krieg@xxxxxxxxxcontact: +55 (86) 9958 9725