Shortest Ruby crash #49

Discussion in 'Ruby' started by Limo Driver, Aug 19, 2008.

  1. Limo Driver

    Limo Driver Guest

    My contribution to the contest:

    5**6**7

    This baby throws "Errno::EBADF: Bad file descriptor", which I think
    deserves a medal for being the least intuitive error message of 2008!

    And now, for the real question...

    Why is this being evaluated as 5**(6**7), when for instance 9/9/9 is
    being evaluated normally (9/9)/9=0, instead of 9/(9/9)=9?

    Lata!
     
    Limo Driver, Aug 19, 2008
    #1
    1. Advertising

  2. On Aug 19, 2008, at 3:36 PM, Limo Driver wrote:

    > My contribution to the contest:
    >
    > 5**6**7
    >
    > This baby throws "Errno::EBADF: Bad file descriptor", which I think
    > deserves a medal for being the least intuitive error message of 2008!
    >
    > And now, for the real question...
    >
    > Why is this being evaluated as 5**(6**7), when for instance 9/9/9 is
    > being evaluated normally (9/9)/9=0, instead of 9/(9/9)=9?
    >
    > Lata!



    Mine is fine with it:
    irb> 5**6**7
    (irb):17: warning: in a**b, b may be too big
    => Infinity

    What ruby do you have that crashes?

    -Rob

    Rob Biedenharn http://agileconsultingllc.com
     
    Rob Biedenharn, Aug 19, 2008
    #2
    1. Advertising

  3. Limo Driver

    Dave Thomas Guest

    On Aug 19, 2008, at 2:36 PM, Limo Driver wrote:

    > My contribution to the contest:
    >
    > 5**6**7


    On 1.9, I get a number of 195,667 digits that starts 736 and ends 635.

    Dave
     
    Dave Thomas, Aug 19, 2008
    #3
  4. Limo Driver <> writes:

    > My contribution to the contest:
    >
    > 5**6**7
    >
    > This baby throws "Errno::EBADF: Bad file descriptor", which I think
    > deserves a medal for being the least intuitive error message of 2008!


    Works fine for me:

    $ irb
    irb(main):001:0> 5**6**7
    => 73643396061195573182045442760389697209119043099561473825102644208480
    80271451222449204242010655986286553096951684440491235491489097071221600
    73189280314561194164500176158310362022388644790243471934093460794441233
    52773742517692136546608518658769275630499890833988104996453386858963527
    .....
    and so on

    this on my locally compiled irb 0.9.5(05/04/13) on debian

    > And now, for the real question...
    >
    > Why is this being evaluated as 5**(6**7), when for instance 9/9/9 is
    > being evaluated normally (9/9)/9=0, instead of 9/(9/9)=9?


    What makes you think either order is the "normal" one?

    --
    Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
     
    Joost Diepenmaat, Aug 19, 2008
    #4
  5. Limo Driver

    Limo Driver Guest

    I've installed ruby exactly 8 minutes ago.
    Managed to crash it with my fifth 'Hello World' attempt.

    ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]

    It's not really about the crash, it's about the interesting operation
    precedence.
     
    Limo Driver, Aug 19, 2008
    #5
  6. Limo Driver

    Limo Driver Guest

    It seems your kung-fu is stronger than mine. :p

    Fine than, try 9**9**9. Ouch.
     
    Limo Driver, Aug 19, 2008
    #6
  7. Limo Driver wrote:
    > Why is this being evaluated as 5**(6**7), when for instance 9/9/9 is
    > being evaluated normally (9/9)/9=0, instead of 9/(9/9)=9?

    Exponentiation has reverse precedence as compared to division,
    multiplication, etc.
    --
    Posted via http://www.ruby-forum.com/.
     
    Joshua Ballanco, Aug 19, 2008
    #7
  8. Limo Driver

    Limo Driver Guest

    Well, I kindof gathered that so far :/

    Now I'm just trying to poke at the "Principle of Least Astonishment".
     
    Limo Driver, Aug 19, 2008
    #8
  9. On Tue, Aug 19, 2008 at 12:36 PM, Limo Driver <> wrote:>
    > Why is this being evaluated as 5**(6**7), when for instance 9/9/9 is
    > being evaluated normally (9/9)/9=0, instead of 9/(9/9)=9?


    Ruby follows the actual mathematical usage, where a^b^c (imagine it
    written in tower form) is a^(b^c). I guess this is because (a^b)^c =
    a^(bc), so a^(b^c) was the case that needed the compact notation

    martin
     
    Martin DeMello, Aug 19, 2008
    #9
  10. Limo Driver

    Tim Hunter Guest

    Limo Driver wrote:
    > I've installed ruby exactly 8 minutes ago.
    > Managed to crash it with my fifth 'Hello World' attempt.
    >
    > ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]
    >
    > It's not really about the crash, it's about the interesting operation
    > precedence.


    I tried with the identical version of Ruby on WinXP and I get the "b may
    be too large" message. No crash.
    --
    Posted via http://www.ruby-forum.com/.
     
    Tim Hunter, Aug 20, 2008
    #10
  11. Limo Driver

    Robert Dober Guest

    On Tue, Aug 19, 2008 at 9:44 PM, Dave Thomas <> wrote:
    >
    > On Aug 19, 2008, at 2:36 PM, Limo Driver wrote:
    >
    >> My contribution to the contest:
    >>
    >> 5**6**7

    >
    > On 1.9, I get a number of 195,667 digits that starts 736 and ends 635.

    ...containing 42 exactly 1922 times.
    R.
     
    Robert Dober, Aug 20, 2008
    #11
  12. On 19.08.2008, at 21:44, Dave Thomas wrote:
    > On Aug 19, 2008, at 2:36 PM, Limo Driver wrote:
    >
    >> My contribution to the contest:
    >>
    >> 5**6**7

    >
    > On 1.9, I get a number of 195,667 digits that starts 736 and ends 635.


    Really?
    With 1.9 and 1.8.7, I get a number that starts with the same and ends =20=

    with
    625. I hope it's just a typo.

    $ ruby --version
    ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-darwin8]
    $ ruby19 --version
    ruby 1.9.0 (2008-08-18 revision 0) [i386-darwin8.11.1]


    regards, Sandor Sz=FCcs
    --
     
    Sandor Szücs, Aug 20, 2008
    #12
  13. Limo Driver

    Robert Dober Guest

    On Wed, Aug 20, 2008 at 11:38 AM, Sandor Sz=FCcs
    <> wrote:
    >
    > On 19.08.2008, at 21:44, Dave Thomas wrote:
    >>
    >> On Aug 19, 2008, at 2:36 PM, Limo Driver wrote:
    >>
    >>> My contribution to the contest:
    >>>
    >>> 5**6**7

    >>
    >> On 1.9, I get a number of 195,667 digits that starts 736 and ends 635.

    >
    > Really?
    > With 1.9 and 1.8.7, I get a number that starts with the same and ends wit=

    h
    > 625. I hope it's just a typo.

    If I remember modulo calculations from school correctly it surely is a typo=
    ;)
    R.
     
    Robert Dober, Aug 20, 2008
    #13
  14. Limo Driver wrote:
    > My contribution to the contest:
    >
    > 5**6**7
    >
    > This baby throws "Errno::EBADF: Bad file descriptor", which I think
    > deserves a medal for being the least intuitive error message of 2008!
    >
    > And now, for the real question...
    >
    > Why is this being evaluated as 5**(6**7), when for instance 9/9/9 is
    > being evaluated normally (9/9)/9=0, instead of 9/(9/9)=9?


    Appears to be working fine on JRuby trunk.

    - Charlie
     
    Charles Oliver Nutter, Aug 20, 2008
    #14
    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. ThanhVu Nguyen
    Replies:
    6
    Views:
    5,821
    Karl Heinz Buchegger
    Aug 24, 2004
  2. Webdad
    Replies:
    20
    Views:
    1,911
    Jochus
    Dec 9, 2004
  3. Stewart Gordon

    Shortest possible valid HTML document?

    Stewart Gordon, May 30, 2006, in forum: HTML
    Replies:
    10
    Views:
    2,399
    David Håsäther
    Jun 2, 2006
  4. swisscheese

    Shortest prime number program

    swisscheese, Feb 11, 2006, in forum: Python
    Replies:
    19
    Views:
    635
    Tim Hochberg
    Feb 13, 2006
  5. henon

    shortest nozero ruby quine

    henon, Oct 18, 2003, in forum: Ruby
    Replies:
    14
    Views:
    242
    Sean Ross
    Dec 18, 2003
Loading...

Share This Page