Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
order of operations
#11
We were taught to do that, with the teacher saying it would be easier. However, it makes myself error prone: both the turning part and the addition part is buggy.. :\
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#12
as the discussion indicates, there is much confusion regarding the implementation of precidence on computers. The one thing you can take to the bank, is that parentheses work on all systems...and are evaluated from the inside out before anything else is done. If you write code and omit parentheses to "show your stuff" (that you understand precidence on the system the code was designed for so well that you dont *need* any friggin' parentheses), you do everyone a disservice. If, for example, someone wants to make your code work on another system, and they don't know the QB precidence rules, they will screw it up. The safest and most clear way is to make liberal use of parentheses in your code....even when it's not needed.

x = ((e * (t ^ n)) - p)

rather than

x = e * t ^ n - p

even though they evaluate the same.

if you saw the second expression in a program, you'd wonder what the programmer actually intended. I even go so far as to put parentheses around the whole r-value to avoid problems that will occur if the assignment operator (equals sign) is higher precidence than one of the other operators. This can be the case, though it doesn't come up in QB. For example, the comma operator is lower precidence than the assignment operator in c++
Reply
#13
I can't believe no one on this board recalls "Please Excuse My Dear Aunt Sally". That was 6th grade law (despite being wrong).
i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Reply
#14
Toonski wrote:
Quote:I can't believe no one on this board recalls "Please Excuse My Dear Aunt Sally". That was 6th grade law (despite being wrong).
Actually, a couple of us mentioned it; we just refered to it as PEMDAS. As I tried to say before, it is only wrong when it is misinterpreted (as it usually is by students). When you make a sequential list, something has to go first. If you listed points scored in a basketball game, and Bob and Harry both scored 10 points, you would have to list one before the other even though they are equal:
Code:
Chuck    13
Jose     11
Bob      10
Harry    10
Phil      8
If you only look at the order, you might say Bob did better than Harry. but if you understand enough to look at the scores, you see they did the same.
PEMDAS is a useful teaching tool for helping students to remember order of operations, but to use it properly, they must understand that division is on the same level as multiplication and subtraction is on the same level as addition. Unfortunately, too often they miss this, and unfortunately too often teachers don't stress it or understand it themselves.
hrist Jesus came into the world to save sinners, of whom I am first.(I Timothy 1:15)

For God so loved the world, that He gave His only begotten Son,
that whoever believes in Him should not perish, but have eternal life.(John 3:16)
Reply
#15
I was referring to the sentence itself, fox, like "every good boy deserves fudge" for remembering music notes.
i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Reply
#16
Quote:I can't believe no one on this board recalls "Please Excuse My Dear Aunt Sally". That was 6th grade law (despite being wrong).
i know it... and if you hadn't said it i would have.
so its...
Parathesis
Exponents
Multiplication/Division (left to right)
Add/Subtract (left to right)

sry for the spelling
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#17
Wow I can't believe that this is a big issue or a question!

PEM/DA/S just like you guys said, M/D, because you go left to right. So

3 * 4 / 2 = 6

BECAUSE... 3 * 4 = 12 / 2 = 6

and that's really all there is to it. I don't know why it's so confusing to some...
ovaProgramming.

One night I had a dream where I was breaking balls. The next morning, BALLSBREAKER was born.

Quote: Excellent. Now you can have things without paying for them.

BALLSBREAKER 2
~-_-Status Report-_-~
Engine: 94%
Graphics: 95%
Sound: 100%
A Severe Error has crippled BB2 for the time being... I have to figure it out, but until then you won't see much of it Sad.
-----------------------------
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)