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.
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
Re: Basic Algebraic formulas in C++
Yea that is true, not sure what PEDMAS is, unless that is something like BODMAS.
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.
Re: Basic Algebraic formulas in C++
cool :)
what is this Wikipedia you speak of? :P
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. :rolleyes:
Yes, PEMDAS is an acronym based upon the Order of Operations.