Sunday, April 6, 2008

Divison in Python, versus Ruby

Just started on Python 101...

Invoked the command line interpreter, and noticed something interesting while playing with it...

Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> 1/2.0
0.5
>>> 1/10.0
0.10000000000000001
>>> 1/3.0
0.33333333333333331
>>>


Hmm... why is there a "tail" left behind? :P

Started up my Ruby interpreter, just to peform a comparison...

C:\Users\xq>irb
irb(main):001:0> 1/2.0
=> 0.5
irb(main):002:0> 1/10.0
=> 0.1
irb(main):004:0> 1/3.0
=> 0.333333333333333
irb(main):005:0>

Cool... :P

No comments: