Forum > General

Math question

(1/11) > >>

bylaardt:
-2² = ?
I know! obvious "-4", but :

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Symbolic.QuickEvaluate('-2^2',[],[]))returns 4
Other expressions parsers based on rpn conversion, return "4" too.
spreedshets like Libreoffice, GoogleSheets (https://www.google.com/sheets/about/) retur "4"

is this a collective bug or a expected behavior?

PS: 0-2^2 returns "-4" as expected.

howardpc:
It is a question of interpretation.
Does -2² mean (-2)*(-2) or -(2²)?

Mathematician's conventions may differ from programmers or writers of scripting languages.

wp:
See the section on "Exceptions" in https://en.wikipedia.org/wiki/Order_of_operations

Use parenthesis for clarification: (-2)^2 = 4  or -(2^2) = -4

taazz:

--- Quote from: bylaardt on February 23, 2016, 07:18:23 pm ----2² = ?
is this a collective bug or a expected behavior?

--- End quote ---
Any negative multiple by a negative number it will yield a positive number. It is basic multiplication theory http://www.mathsisfun.com/multiplying-negatives.html

taazz:

--- Quote from: howardpc on February 23, 2016, 07:29:29 pm ---It is a question of interpretation.
Does -2² mean (-2)*(-2) or -(2²)?

Mathematician's conventions may differ from programmers or writers of scripting languages.

--- End quote ---
no its not, if there is no parenthesis specified then your first interpretation is implied.

Navigation

[0] Message Index

[#] Next page

Go to full version