Host Engineering Forum
General Category => Do-more CPUs and Do-more Designer Software => Topic started by: amezcackle on November 03, 2015, 05:38:31 PM
-
Is there a reason why designer performs multiplication before exponents in it's math operations? For example, an equation entered like this:
2 * 2 ^ 2
is rendered like this for a result of 16:
(2 * 2) ^ 2
Is it not usually performed like this for a result of 8?:
2 * (2 ^ 2)
Mike
-
^ is XOR, not raised to power. Do-more uses C/C++/C#/java syntax in its MATH expressions, so ^ is XOR.
However, those languages do not have a raised-to-power operator, so we stole one from the old BASIC language, ** (two asterisks).
So try 2 * 2 ** 2. You will see the automagic placement of the parentheses as you expected: 2 * (2 ** 2)
-
^ is XOR, not raised to power. Do-more uses C/C++/C#/java syntax in its MATH expressions, so ^ is XOR.
However, those languages do not have a raised-to-power operator, so we stole one from the old BASIC language, ** (two asterisks).
So try 2 * 2 ** 2. You will see the automagic placement of the parentheses as you expected: 2 * (2 ** 2)
Thanks, that's helpful.
Mike
-
So I had to check. I found (2*2)^2 is actually 6 in the Do-more, since in binary:
(010*010) XOR 010 = 100 XOR 010 = 110
which is 6 in decimal.
(I also noted * and ^ are easy to misread at 85% zoom in the ladder.)
-
which is 6 in decimal
Even worse!
Oops! Getting closer! ;D