Results 1 to 6 of 6

Thread: Basic Algebraic formulas in C++

  1. #1

    Thread Starter
    Fanatic Member hothead's Avatar
    Join Date
    Mar 2002
    Location
    Missouri
    Posts
    692

    Basic Algebraic formulas in C++

    Hey guys, I'm trying to move on to C++. Basically, the problem is that I need to translate the following formula into computer code:

    I want it to compute the result of intWidth + (intWidth / 2)

    Using PEMDAS, we would divide intWidth by 2 first, then add intWidth to the result. I'm sure most of you already know this, but there it is just in case.

  2. #2
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Basic Algebraic formulas in C++

    I think all compilers follow basic operator precedence. Therefore, that equation in C++ is the same as you've shown it.

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  3. #3
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: Basic Algebraic formulas in C++

    Yea that is true, not sure what PEDMAS is, unless that is something like BODMAS.

  4. #4
    Fanatic Member McCain's Avatar
    Join Date
    Jan 2002
    Location
    Sweden/Denmark
    Posts
    802

    Re: Basic Algebraic formulas in C++

    It depends on what part of the world you're from
    Quote Originally Posted by wikipedia
    In the United States, the acronym PEMDAS (for Parentheses, Exponentiation, Multiplication/Division, Addition/Subtraction) is used instead, sometimes expressed as the mnemonic "Please Excuse My Dear Aunt Sally", "Please Execute My Dumb Assassin Sam", "Panda Express Makes Delicious Avocado Soup, or "Please Excuse My Deadly Angry Samurai."

    In Canada, an acronym BEDMAS is often used as a mnemonic for Brackets, Exponents, Division, Multiplication, Addition, and Subtraction.

    In the UK, Australia and New Zealand, the acronym BODMAS is commonly used for Brackets, Orders, Division, Multiplication, Addition, Subtraction. Since multiplication and division are of the same rank, this is sometimes written as BOMDAS, BIDMAS or BIMDAS where I stands for Indices.
    Never argue with fools, they will only drag you down to their level, and beat you with experience.

    Q: How do you tell an experienced hacker from a novice?
    A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer

  5. #5
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: Basic Algebraic formulas in C++

    cool
    what is this Wikipedia you speak of? :P

  6. #6

    Thread Starter
    Fanatic Member hothead's Avatar
    Join Date
    Mar 2002
    Location
    Missouri
    Posts
    692

    Re: Basic Algebraic formulas in C++

    Thanks guys, it's just that I was getting an error when I tried it the normal way, and I realize now that there was an extra character that didn't belong.

    Yes, PEMDAS is an acronym based upon the Order of Operations.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width