rolyaTy
You're Heinous
You can make a program work most any way you want. If I wanted to write a program to do order of operations stuff, I would include a negative sign seperate from the minus sign. Programs can and do run that way, I have a calculator that does just that as proof.Again, a computer program is only as good as the person using it. If the person using it doesn't understand that there is a difference between writing -5^2 and (-5)^2, it's not the computers fault. The job of the person is to put the mathematical equation into terms that the computer can understand.Programs don't work that way.I'm just saying... that any business apps that include exponentiation that could possibly be given a negative number are going to calculate incorrectly, based on what I have learned here.I would make a specific operator for negative values separate from a minus sign, like most calculators do. If someone uses the operator representing a sign...then it'd be -5, if they use the operator representing subtraction, it'd be -(5).So, how would you put the original equation in code? Assuming intNumber is the variable to be taken to the 2nd power, I would code it as (intNumber^2). If intNumber is set to -5, the processor comes calculates this as 25 not -25. Same if you make it (intNumber)^2.No, just like with google, calculators and excel, one must understand how to use them before expecting them to churn out correct answers. If you were to use parentheses like you're supposed to, the computers do fine with them. Even without parenthesis, the computers do the calculations correctly...it's just that we think we're telling the computer to do one thing, when we're really telling it something else.OK, so now I'm convinced due to the order of operations that -5^2 should be -25. However, I fear that most if not all computer programs ever written and interpreted on current processors is doing it wrong.
To force the processor to intrepret it correctly would mean changing every formula that includes exponentiation to check for a negative base number and if found change the formula from something like x^2 to (-1*(x)^2). Otherwise, it comes out positive every time.
I think this could be a new Y2K for us programmers.
Will one of you alert the news media? I'll be getting my business cards ready. Swapster, Negative Exponentiation Specialist.
To force them to calculate correctly would take a lot of programming changes, looking for a negative being fed into the equation (not by a human operator but from elsewhere in the program - it could be a result of a previous calculation done on numbers from a database, for instance).
The computer program will not calculate incorrectly - the person would have INPUT the problem incorrectly.
There are plenty of calculators out there that don't follow PEMDAS, that calculate 100% correctly. The users have to know how to enter the info, and to do that they have to understand order of operations themselves, which apparently isn't as common as I suspected.