Recently we had reason to use an infix calculator I wrote. During testing two questions came up and I' seeking other opinions.
The first was concerning expressions like -9^2. What does that equal? Pumping that into the Google search bar or Wolfram Alpha it equals -81.
But it appears that both interpret that to mean -(9^2).
The second question was my implementation of multiplication by juxtaposition, especially my giving it a higher precedence than regular multiplication. e.g.
6/2(2+1) = 1 multiplication by juxtaposition
6/2*(2+1)=9
For those unfamiliar with multiplication by juxtaposition here is an explanation.
https://www.youtube.com/watch?v=lLCDca6dYpA
In the section labeled Current Calculators in the link below it seems that not all calculators answer the same.
https://www.youtube.com/watch?v=4x-BcYCiKCk
Here are all of the test ran. Format is expression TAB answer. All numbers represented by decimal.
Math.Pow Test
The first was concerning expressions like -9^2. What does that equal? Pumping that into the Google search bar or Wolfram Alpha it equals -81.
But it appears that both interpret that to mean -(9^2).
The second question was my implementation of multiplication by juxtaposition, especially my giving it a higher precedence than regular multiplication. e.g.
6/2(2+1) = 1 multiplication by juxtaposition
6/2*(2+1)=9
For those unfamiliar with multiplication by juxtaposition here is an explanation.
https://www.youtube.com/watch?v=lLCDca6dYpA
In the section labeled Current Calculators in the link below it seems that not all calculators answer the same.
https://www.youtube.com/watch?v=4x-BcYCiKCk
Here are all of the test ran. Format is expression TAB answer. All numbers represented by decimal.
Code:
6/2(2+1) 1
6/2*(2+1) 9
84/14*9/18 3
22/7 3.1428571428571428571428571429
7(3.1428571428571428571428571427) 21.999999999999999999999999999
-4(2+3)/(8-6) -10
-4(2-3^2)/(8-6) 14
3-5^2 -22
3(2+5) 21
3/3(2+5) 0.1428571428571428571428571429
3/3*(2+5) 7
4*3(4-2(6-3))/3 -8
(8-6)+10 12
(5*9)/(10+5) 3
(8*8)-(11*4) 20
((40*2)-10)/5 14
(16*6)+(30+5) 131
56-25-12/48-29 1.75
20*5-12*5*60-55 -3555
(20*5-12*5*60-55)%10 -5
-1^2 1
-2^2 4
-(2^2) -4
0-3^2 -9
-3^5 -243
3^-2 0.111111111111111
-3^-2 0.111111111111111
0.5^3 0.125
-0.5^3 -0.125
1,000^2 1000000
√0 0
√24 4.89897948556636
sqrt(24) 4.89897948556636
Code:
For d As Double = 1.0# To 5.0# Step 1.0#
Dim ans As Double = Math.Pow(-2.0#, d)
Debug.WriteLine("-2 raised to {0} = {1}?", d, ans)
Next