From: Jeppe Jakobsen Date: 2006-04-02T08:55:23+09:00 Subject: Re: Newbie! Programming Calculations ------=_Part_15655_12582878.1143935721102 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Ruby follow the laws of math. That means the a + multiplied by a - (which i= s really what +- means, but it's just not written that way) will result in a -. That leads to: +-15 =3D -15. Here is the a thumb rule for remembering what the parentheses (brackets) ar= e for, that I learned in one of my first years with math: When a calculation is inside a parenthesis it is saying: "Calculate me first!" When doing really advanced calculations, it's a good idea to put a lot of parentheses so that the computer and you agree on which mathematical operations are to be done first. If you want more info, on this particular subject, you should try googling for math rather than ruby. 2006/4/2, Indifferent : > > Im new to programming, im learning ruby. > > Here is the guide I am working through: > http://pine.fm/LearnToProgram/?Chapter=3D01 > > At the bottom of the page there are these sample calculations: > puts 5 * (12-8) + -15 (is that + minus15 or does the + and the - mean > something combined? same for the one below with * and -52) > puts 98 + (59872 / (13*8)) * -52 > > What do they do? What are the brackets for? > I sort of remember doing something simular to this when I was using > excel in a course i did. Is the number is the brackets calculated first? > Can someone explain this to me? Or give me a link were I can find more > information. > > Extreamly confused newbie! Please help! > > -- > Posted via http://www.ruby-forum.com/. > > -- "winners never quit, quitters never win" ------=_Part_15655_12582878.1143935721102--