|
-
Jun 16th, 2007, 05:13 PM
#1
Thread Starter
Fanatic Member
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.
-
Jun 17th, 2007, 02:17 AM
#2
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
-
Jun 17th, 2007, 03:33 AM
#3
Re: Basic Algebraic formulas in C++
Yea that is true, not sure what PEDMAS is, unless that is something like BODMAS.
-
Jun 17th, 2007, 04:59 AM
#4
Fanatic Member
Re: Basic Algebraic formulas in C++
It depends on what part of the world you're from 
 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
-
Jun 17th, 2007, 05:27 AM
#5
Re: Basic Algebraic formulas in C++
cool
what is this Wikipedia you speak of? :P
-
Jun 17th, 2007, 11:21 AM
#6
Thread Starter
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|