Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Shortest Ruby crash #49

Reply
Thread Tools

Shortest Ruby crash #49

 
 
Limo Driver
Guest
Posts: n/a
 
      08-19-2008
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!
 
Reply With Quote
 
 
 
 
Rob Biedenharn
Guest
Posts: n/a
 
      08-19-2008

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
http://www.velocityreviews.com/forums/(E-Mail Removed)



 
Reply With Quote
 
 
 
 
Dave Thomas
Guest
Posts: n/a
 
      08-19-2008

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

 
Reply With Quote
 
Joost Diepenmaat
Guest
Posts: n/a
 
      08-19-2008
Limo Driver <(E-Mail Removed)> 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
=> 73643396061195573182045442760389697209119043099561 473825102644208480
80271451222449204242010655986286553096951684440491 235491489097071221600
73189280314561194164500176158310362022388644790243 471934093460794441233
52773742517692136546608518658769275630499890833988 104996453386858963527
.....
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/
 
Reply With Quote
 
Limo Driver
Guest
Posts: n/a
 
      08-19-2008
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.
 
Reply With Quote
 
Limo Driver
Guest
Posts: n/a
 
      08-19-2008
It seems your kung-fu is stronger than mine.

Fine than, try 9**9**9. Ouch.
 
Reply With Quote
 
Joshua Ballanco
Guest
Posts: n/a
 
      08-19-2008
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/.

 
Reply With Quote
 
Limo Driver
Guest
Posts: n/a
 
      08-19-2008
Well, I kindof gathered that so far :/

Now I'm just trying to poke at the "Principle of Least Astonishment".
 
Reply With Quote
 
Martin DeMello
Guest
Posts: n/a
 
      08-19-2008
On Tue, Aug 19, 2008 at 12:36 PM, Limo Driver <(E-Mail Removed)> 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

 
Reply With Quote
 
Tim Hunter
Guest
Posts: n/a
 
      08-19-2008
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/.

 
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
Shortest possible valid HTML document? Stewart Gordon HTML 10 06-02-2006 10:51 AM
Recursive algoritme for finding the shortest path Webdad C++ 20 12-09-2004 06:51 PM
Shortest path algorithm (other than Dijkstra) ThanhVu Nguyen C++ 6 08-24-2004 12:50 PM
CRASH - DirectX End-User runtime - CRASH - What to to ? reply@newsgroup.please Computer Support 1 01-05-2004 02:55 PM
shortest nozero ruby quine henon Ruby 14 12-18-2003 05:18 PM



Advertisments