Real constants and functions: Difference between revisions

Added solution for Action!
No edit summary
(Added solution for Action!)
Line 67:
-floor(-x);
enddefine;</lang>
 
=={{header|Action!}}==
Part of the solution can be find in [http://www.rosettacode.org/wiki/Category:Action!_Real_Math REALMATH.ACT].
{{libheader|Action! Tool Kit}}
{{libheader|Action! Real Math}}
<lang Action!>INCLUDE "H6:REALMATH.ACT"
 
PROC Euler(REAL POINTER e)
REAL x
 
IntToReal(1,x)
Exp(x,e)
RETURN
 
PROC Main()
REAL a,b,c
INT i
 
Put(125) PutE() ;clear screen
MathInit()
 
Euler(a)
Print("e=") PrintR(a)
PrintE(" by Exp(1)")
 
ValR("2",a)
Sqrt(a,b)
Print("Sqrt(") PrintR(a)
Print(")=") PrintR(b)
Print(" by Power(") PrintR(a)
PrintE(",0.5)")
 
ValR("2.5",a)
Ln(a,b)
Print("Ln(") PrintR(a)
Print(")=") PrintRE(b)
 
ValR("14.2",a)
Log10(a,b)
Print("Log10(") PrintR(a)
Print(")=") PrintRE(b)
 
ValR("-3.7",a)
Exp(a,b)
Print("Exp(") PrintR(a)
Print(")=") PrintRE(b)
 
ValR("2.6",a)
Exp10(a,b)
Print("Exp10(") PrintR(a)
Print(")=") PrintRE(b)
 
ValR("25.3",a)
ValR("1.3",b)
Power(a,b,c)
Print("Power(") PrintR(a)
Print(",") PrintR(b)
Print(")=") PrintRE(c)
 
ValR("-32.5",a)
RealAbs(a,b)
Print("Abs(") PrintR(a)
Print(")=") PrintR(b)
PrintE(" by bit manipulation")
 
ValR("23.15",a)
i=Floor(a)
Print("Floor(") PrintR(a)
PrintF(")=%I by own function%E",i)
 
ValR("-23.15",a)
i=Floor(a)
Print("Floor(") PrintR(a)
PrintF(")=%I by own function%E",i)
 
ValR("23.15",a)
i=Ceiling(a)
Print("Ceiling(") PrintR(a)
PrintF(")=%I by own function%E",i)
 
ValR("-23.15",a)
i=Ceiling(a)
Print("Ceiling(") PrintR(a)
PrintF(")=%I by own function%E",i)
 
PutE()
PrintE("There is no support in Action! for pi.")
RETURN</lang>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Real_constants_and_functions.png Screenshot from Atari 8-bit computer]
<pre>
e=2.71828179 by Exp(1)
Sqrt(2)=1.41421355 by Power(2,0.5)
Ln(2.5)=.9162907319
Log10(14.2)=1.15228834
Exp(-3.7)=.0247235365
Exp10(2.6)=398.106988
Power(25.3,1.3)=66.6893784
Abs(-32.5)=32.5 by bit manipulation
Floor(23.15)=23 by own function
Floor(-23.15)=-24 by own function
Ceiling(23.15)=24 by own function
Ceiling(-23.15)=-23 by own function
 
There is no support in Action! for pi.
</pre>
 
=={{header|ActionScript}}==
Anonymous user