Bugs item #6468, was opened at 2006-11-03 17:25
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=1698&aid=6468&group_id=426

Category: Core
Group: 1.8.5
Status: Open
Resolution: None
Priority: 3
Submitted By: Boris Schmid (bor_)
Assigned to: Nobody (None)
Summary: the sign of a number is omitted when squaring it. -2**2 vs (-2)**2

Initial Comment:
Due to the way ruby interprets formula's, squaring a negative number isn't possible unless you use brackets. This caught me unaware, and might be counterintuitive for more people.


irb(main):018:0> -2**2
=> -4
irb(main):019:0> (-2)**2
=> 4


Some trouble:
irb(main):006:0> 3-2**2
=> -1
The above works fine right now, but only because it is seen as 3 - 2**2. If "-2" is recognized as a negative number, and "- 2" as 'substract 2, then the 3-2**2 example should rise an error.


----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=1698&aid=6468&group_id=426