|
From: | anonymous |
Subject: | [Octave-bug-tracker] [bug #37734] Octave produces incorrect results because it doesn't follow the normal order of operations |
Date: | Wed, 14 Nov 2012 18:38:10 +0000 |
User-agent: | Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:16.0) Gecko/20100101 Firefox/16.0 |
URL: <http://savannah.gnu.org/bugs/?37734> Summary: Octave produces incorrect results because it doesn't follow the normal order of operations Project: GNU Octave Submitted by: None Submitted on: Wed 14 Nov 2012 06:38:08 PM UTC Category: Interpreter Severity: 3 - Normal Priority: 5 - Normal Item Group: Incorrect Result Status: None Assigned to: None Originator Name: Georgiy Treyvus Originator Email: address@hidden Open/Closed: Open Discussion Lock: Any Release: 3.2.4 Operating System: GNU/Linux _______________________________________________________ Details: Here is the bug: octave:1> 2^3^2 ans = 64 octave:2> The answer is supposed to be 512 yet Octave returns 64 here instead. The reason is that it's not following the correct order of operations. It evaluates the expression I fed it as (2^3)^2 as opposed to 2^(3^2) as it's supposed to if expressions were evaluated by normal order of operations. This bug isn't a big deal as I can simply feed Octave 2^(3^2) to get the correct answer. However even though the workaround is quite trivial inserting these extra parentheses is not something I should have to do. The goes against well established mathematical standards and against the behaviors of just about every other interpreter I've seen whether specialized for mathematical purposes or not. Python: >>> 2**3**2 512 Ruby: irb(main):001:0> 2**3**2 => 512 Bash: address@hidden:~$ echo $((2**3**2)) 512 Qalculate: > 2^3^2 2^(3^2) = 512 R: > 2^3^2 [1] 512 Scilab: -->2^3^2 ans = 512. Bc: 2^3^2 512 Please fix this to behave in accordance with mathematical norms. _______________________________________________________ Reply to this item at: <http://savannah.gnu.org/bugs/?37734> _______________________________________________ Message sent via/by Savannah http://savannah.gnu.org/
[Prev in Thread] | Current Thread | [Next in Thread] |