Real constants and functions: Difference between revisions

Rename Perl 6 -> Raku, alphabetize, minor clean-up
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 25:
<lang Lisp>(floor 15 2) ;; This is the floor of 15/2
(ceiling 15 2)
(expt 15 2) ;; 15 squared</lang> =={{header|ACL2}}==
Only the last three are available as built in functions.
 
loor and ceiling are not provided, one can
define them using integer part:
 
<lang pop11>define floor(x);
if x < 0 then
-intof(x);
else
intof(x);
endif;
enddefine;
 
define ceiling(x);
-floor(-x);
enddefine;</lang>
 
=={{header|ActionScript}}==
Line 412 ⟶ 428:
 
To access the M_PI, etc. constants in Visual Studio, you may need to add the line <code>#define _USE_MATH_DEFINES</code> before the <code>#include <math.h></code>.
 
=={{header|C sharp}}==
<lang csharp>using System;
 
class Program {
static void Main(string[] args) {
Console.WriteLine(Math.E); //E
Console.WriteLine(Math.PI); //PI
Console.WriteLine(Math.Sqrt(10)); //Square Root
Console.WriteLine(Math.Log(10)); // Logarithm
Console.WriteLine(Math.Log10(10)); // Base 10 Logarithm
Console.WriteLine(Math.Exp(10)); // Exponential
Console.WriteLine(Math.Abs(10)); //Absolute value
Console.WriteLine(Math.Floor(10.0)); //Floor
Console.WriteLine(Math.Ceiling(10.0)); //Ceiling
Console.WriteLine(Math.Pow(2, 5)); // Exponentiation
}
}</lang>
 
=={{header|C++}}==
Line 441 ⟶ 475:
<< "\nceiling(4.5) = " << std::ceil(4.5)
<< "\npi^2 = " << std::pow(pi,2.0) << std::endl;
}</lang>
 
=={{header|C sharp}}==
<lang csharp>using System;
 
class Program {
static void Main(string[] args) {
Console.WriteLine(Math.E); //E
Console.WriteLine(Math.PI); //PI
Console.WriteLine(Math.Sqrt(10)); //Square Root
Console.WriteLine(Math.Log(10)); // Logarithm
Console.WriteLine(Math.Log10(10)); // Base 10 Logarithm
Console.WriteLine(Math.Exp(10)); // Exponential
Console.WriteLine(Math.Abs(10)); //Absolute value
Console.WriteLine(Math.Floor(10.0)); //Floor
Console.WriteLine(Math.Ceiling(10.0)); //Ceiling
Console.WriteLine(Math.Pow(2, 5)); // Exponentiation
}
}</lang>
 
Line 593 ⟶ 609:
? 10 ** 6
# value: 1000000</lang>
 
=={{header|Elena}}==
ELENA 4.x :
Line 867 ⟶ 884:
x^y
</lang>
 
 
=={{header|FutureBasic}}==
Line 1,405 ⟶ 1,421:
math.ceil(x)
x^y</lang>
 
 
=={{header|M2000 Interpreter}}==
Line 1,444 ⟶ 1,459:
Checkit
</lang>
 
 
 
=={{header|Maple}}==
Line 1,942 ⟶ 1,955:
use Math::Complex;
pi; # alternate way to get pi</lang>
 
=={{header|Perl 6}}==
<lang perl6>say e; # e
say π; # or pi # pi
say τ; # or tau # tau
 
# Common mathmatical function are availble
# as subroutines and as numeric methods.
# It is a matter of personal taste and
# programming style as to which is used.
say sqrt 2; # Square root
say 2.sqrt; # Square root
 
# If you omit a base, does natural logarithm
say log 2; # Natural logarithm
say 2.log; # Natural logarithm
 
# Specify a base if other than e
say log 4, 10; # Base 10 logarithm
say 4.log(10); # Base 10 logarithm
say 4.log10; # Convenience, base 10 only logarithm
 
say exp 7; # Exponentiation base e
say 7.exp; # Exponentiation base e
 
# Specify a base if other than e
say exp 7, 4; # Exponentiation
say 7.exp(4); # Exponentiation
say 4 ** 7; # Exponentiation
 
say abs -2; # Absolute value
say (-2).abs; # Absolute value
 
say floor -3.5; # Floor
say (-3.5).floor; # Floor
 
say ceiling pi; # Ceiling
say pi.ceiling; # Ceiling
 
say e ** π\i + 1 ≅ 0; # :-)</lang>
 
=={{header|Phix}}==
Line 2,010 ⟶ 1,983:
ceil(x); //ceiling
pow(x,y); //power</lang>
 
=={{header|PL/I}}==
<lang pli>/* e not available other than by using exp(1q0).*/
/* pi not available other than by using a trig function such as: pi=4*atan(1) */
y = sqrt(x);
y = log(x);
y = log2(x);
y = log10(x);
y = exp(x);
y = abs(x);
y = floor(x);
y = ceil(x);
a = x**y; /* power */
/* extra functions: */
y = erf(x); /* the error function. */
y = erfc(x); /* the error function complemented. */
y = gamma (x);
y = loggamma (x);</lang>
 
=={{header|PicoLisp}}==
Line 2,061 ⟶ 2,016:
123
81.000000000000</pre>
 
=={{header|PL/I}}==
<lang pli>/* e not available other than by using exp(1q0).*/
/* pi not available other than by using a trig function such as: pi=4*atan(1) */
y = sqrt(x);
y = log(x);
y = log2(x);
y = log10(x);
y = exp(x);
y = abs(x);
y = floor(x);
y = ceil(x);
a = x**y; /* power */
/* extra functions: */
y = erf(x); /* the error function. */
y = erfc(x); /* the error function complemented. */
y = gamma (x);
y = loggamma (x);</lang>
 
=={{header|Pop11}}==
Line 2,074 ⟶ 2,047:
 
See also [[Trigonometric Functions]]
 
=={{header|ACL2}}==
Only the last three are available as built in functions.
 
loor and ceiling are not provided, one can
define them using integer part:
 
<lang pop11>define floor(x);
if x < 0 then
-intof(x);
else
intof(x);
endif;
enddefine;
 
define ceiling(x);
-floor(-x);
enddefine;</lang>
 
=={{header|PowerShell}}==
Line 2,156 ⟶ 2,111:
(ceiling x) ; ceiling
(expt x y) ; power</lang>
 
=={{header|Raku}}==
(formerly Perl 6)
<lang perl6>say e; # e
say π; # or pi # pi
say τ; # or tau # tau
 
# Common mathmatical function are availble
# as subroutines and as numeric methods.
# It is a matter of personal taste and
# programming style as to which is used.
say sqrt 2; # Square root
say 2.sqrt; # Square root
 
# If you omit a base, does natural logarithm
say log 2; # Natural logarithm
say 2.log; # Natural logarithm
 
# Specify a base if other than e
say log 4, 10; # Base 10 logarithm
say 4.log(10); # Base 10 logarithm
say 4.log10; # Convenience, base 10 only logarithm
 
say exp 7; # Exponentiation base e
say 7.exp; # Exponentiation base e
 
# Specify a base if other than e
say exp 7, 4; # Exponentiation
say 7.exp(4); # Exponentiation
say 4 ** 7; # Exponentiation
 
say abs -2; # Absolute value
say (-2).abs; # Absolute value
 
say floor -3.5; # Floor
say (-3.5).floor; # Floor
 
say ceiling pi; # Ceiling
say pi.ceiling; # Ceiling
 
say e ** π\i + 1 ≅ 0; # :-)</lang>
 
=={{header|REXX}}==
Line 2,424 ⟶ 2,420:
ceil: 2
Power: 2.28886641</pre>
 
 
=={{header|Rust}}==
Line 2,465 ⟶ 2,460:
println(math.pow(2.5, 3.5)) // power
}</lang>
 
=={{header|Scheme}}==
<lang scheme>(sqrt x) ;square root
Line 2,681 ⟶ 2,677:
-6
-5
1000</pre>
 
=={{header|XPL0}}==
10,327

edits