From: Fleck Jean-Julien Date: 2009-12-19T01:05:41+09:00 Subject: Re: Math errors Hello, > This behavior was shown in ruby ree 1.8.6, 1.8.6, 1.8.7, 1.9.1 > > -27**1/3.0       => -9.0 > -27 ** 1/3.0     => -9.0 > -27 ** (1/3.0)   => -3.0 > -27**(1/3.0)     => -3.0 > (-27)**(1/3.0)   => NaN > (-27) ** (1/3.0) => NaN > > OK, the first two expression are evaluated as (-27**1)/3 => -9 > The second two are correct (what I expected). > But the last two, WHY?? As Matz said, the second two are evaluated as - (27**(1/3.0)), that is you take the cubic root of +27 which is 3 and then distribute the minus. That way, you take the cubic root of a positive number which does not raise any problem. Cheers, -- JJ Fleck PCSI1 Lycée Kléber