Broken lcm

Discussion in 'Ruby' started by Bret Jolly, May 20, 2004.

  1. Bret Jolly

    Bret Jolly Guest

    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
    Bret Jolly, May 20, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Geronimo Stempovski

    HCM / LCM signalling

    Geronimo Stempovski, Feb 7, 2007, in forum: VHDL
    Replies:
    3
    Views:
    572
    Jon Slaughter
    Feb 7, 2007
  2. damian birchler

    no lcm in standard library?

    damian birchler, Sep 13, 2004, in forum: C Programming
    Replies:
    8
    Views:
    394
    Paul Hsieh
    Sep 16, 2004
  3. Steven D'Aprano

    Why are "broken iterators" broken?

    Steven D'Aprano, Sep 21, 2008, in forum: Python
    Replies:
    8
    Views:
    638
  4. Cameron Simpson

    Re: Why are "broken iterators" broken?

    Cameron Simpson, Sep 22, 2008, in forum: Python
    Replies:
    0
    Views:
    570
    Cameron Simpson
    Sep 22, 2008
  5. Replies:
    1
    Views:
    113
Loading...

Share This Page