Join Forum | Login | Today's Posts | Tutorials | Windows 10 Forum | Windows 8 Forum

 Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

# Windows 7: Windows 7 Calculator - Question on the logic for executing functions

 08 Sep 2011 #1 abdulshaik Windows 7 64 bit 2 posts Windows 7 Calculator - Question on the logic for executing functions Hi, When we perform following operation on Win 7 Scenario 1 (9.1*10^ - 31*3*10^8) = we can see the equation getting formed in following way: what we see on the screen is this (9.1*(10- 31*3*10^8)) and result on = comes to following -84629999909 I would like to know on pressing - sign after ^ windows seems to replace the ^ operation with - operation. And when it does that it fails to compute the 9.1*10. To explain, if you execute same math equation with ^ sign i.e. as below: Scenario 2 (9.1*10 - 31*3*10^8) = window shows result as 91 the moment you input - operation in sequence. I predict the same behavior even for the equation where user inputs - sign immediately followed by ^ sign. If window is replacing the - operation with ^ then logically it should do the same what I have explained above in Scenario 2. Not sure what different logic windows is applying here. When I try to execute same logic on JEP Parser (Jep Console - DJep/JEP Java Math Expression Parser) this is what JEP gives as result: JEP > (9.1*10 - 31*3*10^8) -9.299999909E9 It seems there is a bug in the way Windows 7 replaces operation but forgets to execute its preceding operation, even though the precedence of previous operation is HIGH as compared immediate next operation. Let me know if any one observed similar issue and what could be the correct way of implementation here. Thanks in advance. Abdul My System Specs
 .
 08 Sep 2011 #2 Dwarf Windows 8.1 Pro RTM x64 10,375 posts Doncaster, UK Hi Abdul and welcome to W7 Forums I've had a look at this and what I think is happening is this: Normally, operators function in line with the normal hierachial preference (unitary sign, power, multiply and divide, plus and minus) unless the sequence is overridden by the use of parentheses (). A sum is evaluated as it is inputted so long as the hierachial level of each operator is the same or lower than the preceding one. However, when an operator of higher precedence is inputted, things change. In that case, the previous operator is not executed until after the current operation. Let's use an example: A * B ^ C With this, A is multiplied by the result of B risen to the power of C. It is not the result of A multiplied by B and then risen to the power of C. To achieve this, the first term needs to be enclosed in parantheses like this: ( A * B ) ^ C Now, let's assume you made a mistake and that you really wanted to input a minus sign instead of the power. So you enter the following: A * B ^ - C The first term is still waiting for the outcome of the second term before it is executed, even if the operator of that term is corrected from one of higher precedence to an equal or lower one. This is what I think is happening with your equation. You are wanting to raise B to a negative power of C, but instead are inadvertently changing the operator as described above. The correct operation can be done in two ways. First of all, enclose - C in parentheses, so you get A * B ^ ( - C ) Secondly, use the unitary sign key, resulting in A * B ^ C My System Specs
 08 Sep 2011 #3 abdulshaik Windows 7 64 bit 2 posts Got it, Thanks for your response. My System Specs
 .