problème de priorités de calculs

Issue #326 duplicate
Former user created an issue

Originally reported on Google Code with ID 326 ``` What steps will reproduce the problem? 1. -6^2 2. 0-6^2 3. -6^2 + 36

What is the expected output? What do you see instead? -6^2 should give -36 but gives 36 0-6^2 gives correctly -36 -6^2 + 36 gives 72 !

What version of the prvoduct are you using? On what operating system? SpeedCrunch-0.10.1 SpeedCrunch-0.11-alpha

Please provide any additional information below.

```

Reported by `piphi2` on 2010-02-02 19:47:10

Comments (4)

  1. Former user Account Deleted

    ``` PEMDAS http://www.mathgoodies.com/Lessons/vol7/operations_exponents.html Speedcrunch is giving the correct answer. Exponents come before addding/subtracting.

    1. Writing out the exponent will help with this example. 6^2 is really 6*6... 6^3 is

    6*6*6. So -6^2 = (-6)*(-6) = 36 See below website for other examples. http://www.algebra.com/algebra/homework/Signed-numbers/HOW-TO-multiply- negatives.lesson 2. In this example the program will first do the exponent and then subtract. So: 0- 6^2 = 0-36 = -36 3. Since the first example is correct, this would also be correct.

    This is Junior High Algebra. Sorry if this is insulting. ```

    Reported by `Brian.Hall517` on 2010-02-04 14:30:32

  2. Former user Account Deleted

    ``` No problem. This not insulting for me and thnaks for the links. But I think you're wrong. I know this is junior algebra and I know junior algebra. Sorry, I did not introduce myself ... I'm a french math teacher ... Excuse me if my English is not very good.

    I will try to explain why I think speedcrunch is not giving the correct answer. Because exponents come before subtracting, -6^2 must be evaluated as -(6^2) and not as (-6)^2. -6^2 is the opposite of 6^2 so it is equal to -36. You can also see -x as -1*x so -6^2 = -1*6^2 and you see that -1 is not squared (exponents come before multiplicating).

    I guess that speedcrunch see -6 as (-6) but it occurs some mathematical errors (for example : for speedcrunch, what will be the limit of exp(-t^2) when t tend to infinity ?)

    Did i convince you ?

    Another strange answer from Speedcrunch : exp(1000)= 0 ```

    Reported by `piphi2` on 2010-02-06 08:19:01

  3. Former user Account Deleted

    ``` Sorry I just saw the isue 327 and i discovered the precedence of unary minus in some applications or programming languages. I now understand the answers of speedcrunch.

    But the problem is that i can not therefore use speedcrunch with my pupils (12 to 15 years old). I'm disappointed because speedcrunch is the best calculator i had found ...

    Would it be possible to make an option in speedcrunch to switch between the two conventions of unary minus priority ? ```

    Reported by `piphi2` on 2010-02-06 08:37:34

  4. Former user Account Deleted

    ``` piphi2 is right. However, there exist an issue for this already, please see issue 160.

    Although there is a convention that tells SC is behaving correctly, we feel it should

    behave the way you intend, but it takes some effort to fix. Best way all the time in

    any calculator is to make sure we enclose in brackets. I feel sorry about your students, it makes me happy that students are actually using SpeedCrunch. ```

    Reported by `helder.pereira.correia` on 2010-02-07 08:40:09 - Status changed: `Duplicate` - Merged into: #160

  5. Log in to comment