Exponentiation order: Difference between revisions

Added solution for Action!
(Add swift)
(Added solution for Action!)
Line 42:
15625
1.95313e+06
</pre>
 
=={{header|Action!}}==
There is no power operator in Action! Power function for REAL type is used. But the precision is insufficient.
{{libheader|Action! Tool Kit}}
<lang Action!>INCLUDE "D2:REAL.ACT" ;from the Action! Tool Kit
 
PROC Main()
REAL r2,r3,r5,tmp1,tmp2
 
Put(125) PutE() ;clear screen
 
IntToReal(2,r2)
IntToReal(3,r3)
IntToReal(5,r5)
 
PrintE("There is no power operator in Action!")
PrintE("Power function for REAL type is used.")
PrintE("But the precision is insufficient.")
Power(r5,r3,tmp1)
Power(tmp1,r2,tmp2)
Print("(5^3)^2=")
PrintRE(tmp2)
 
Power(r3,r2,tmp1)
Power(r5,tmp1,tmp2)
Print("5^(3^2)=")
PrintRE(tmp2)
RETURN</lang>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Exponentiation_order.png Screenshot from Atari 8-bit computer]
<pre>
There is no power operator in Action!
Power function for REAL type is used.
But the precision is insufficient.
(5^3)^2=15624.9977
5^(3^2)=1953124.17
</pre>
 
Anonymous user