Order of operations - what is 6÷2(1+2) ?
|
12-22-2020, 10:50 PM
Post: #67
|
|||
|
|||
RE: Order of operations - what is 6÷2(1+2) ?
(12-22-2020 08:03 PM)robve Wrote: Yes for Prolog: Prolog should return -4 for this, according to its precedence table. (pow higher than unary minus) Problem is it parsed first number as -2, removed the unary minus. Forcing it to parse first number as 2, we get the right answer. B-Prolog Version 8.1, All rights reserved, (C) Afany Software 1994-2014. | ?- X is -2**2 X = 4 yes | ?- Two = 2, X is -Two**Two Two = 2 X = -4 yes You should not get 2 different answers by replacing Two for 2. This bug had been fixed in Picat Picat> X is -2**2 X = -4 yes Picat> Two = 2, X is -Two**Two Two = 2 X = -4 yes |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)