Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Broken lcm

Reply
Thread Tools

Broken lcm

 
 
Bret Jolly
Guest
Posts: n/a
 
      05-20-2004
Ruby version: ruby 1.9.0 (2004-05-10) [i686-linux]
The lcm method used by mathn (and defined in rational.rb)
is broken.
irb(main):001:0> require 'mathn'
true
irb(main):002:0> 4.lcm(6)
12
irb(main):003:0> 0.lcm(0)
ZeroDivisionError: divided by 0
from /usr/local/lib/ruby/1.9/rational.rb:319:in `div'
from /usr/local/lib/ruby/1.9/rational.rb:319:in `lcm'
from (irb):3
But the lcm of 0 and 0 is well-defined (and equal to 0).

Regards, Bret
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why are "broken iterators" broken? Steven D'Aprano Python 8 09-28-2008 09:19 PM
Re: Why are "broken iterators" broken? Cameron Simpson Python 0 09-22-2008 04:32 AM
HCM / LCM signalling Geronimo Stempovski VHDL 3 02-07-2007 03:38 PM
rational.rb Integer#lcm correction erlercw@siu.edu Ruby 1 11-15-2004 01:53 AM
no lcm in standard library? damian birchler C Programming 8 09-16-2004 08:03 PM



Advertisments