Real constants and functions: Difference between revisions

→‎{{header|BASIC}}: Added ANSI BASIC.
(→‎{{header|BASIC}}: Added ANSI BASIC.)
(4 intermediate revisions by 3 users not shown)
Line 415:
 
=={{header|BASIC}}==
==={{header|QBasicANSI BASIC}}===
{{trans|True BASIC|In fact, True BASIC implements ANSI BASIC, but adds some other features.}}
{{works with|QBasic|1.1}}
{{works with|QuickBasic|4.5Decimal BASIC}}
<syntaxhighlight lang="qbasicbasic">'ceiling and floor easily implemented as functions.
100 REM Real constants and functions
'e & pi not available- calculate as shown.
110 DECLARE EXTERNAL FUNCTION Floor
 
120 PRINT "e = "; EXP(1) ! e not available
FUNCTION ceiling (x)
130 PRINT "PI = "; PI
IF x < 0 THEN ceiling = INT(x) ELSE ceiling = INT(x) + 1
140 LET X = 12.345
END FUNCTION
150 LET Y = 1.23
 
160 PRINT "sqrt = "; SQR(X), X ^ 0.5 ! square root- NB the unusual name
FUNCTION floor (x)
170 PRINT "ln = "; LOG(X) ! natural logarithm base e
IF x > 0 THEN
180 PRINT "log2 = "; LOG2(X) ! base 2 logarithm
floor = INT(x)
190 PRINT "log10 = "; LOG10(X) ! base 10 logarithm
ELSE
200 PRINT "log = "; LOG(X) / LOG(Y) ! arbitrary base logarithm
IF x <> INT(x) THEN floor = INT(x) - 1 ELSE floor = INT(x)
210 PRINT "exp = "; EXP(X) ! exponential
END IF
220 PRINT "abs = "; ABS(-1) ! absolute value
END FUNCTION
230 PRINT "floor = "; Floor(X) ! floor easily implemented as functions
 
240 PRINT "e ceil = "; EXPCEIL(1X) ! ' e not availableceiling
250 PRINT "PI power = "; 4X ^ *Y ATN(1) ' pi not! availablepower
260 END
270 REM **
x = 12.345: y = 1.23
280 EXTERNAL FUNCTION Floor(X)
290 IF X > 0 THEN
PRINT "sqrt = "; SQR(x), x ^ .5 ' square root- NB the unusual name
300 LET Floor = INT(X)
PRINT "ln = "; LOG(x) ' natural logarithm base e
310 ELSE
PRINT "log10 = "; LOG(x) / 2.303 ' base 10 logarithm
PRINT320 "log =IF ";X LOG<> INT(xX) /THEN LOGLET Floor = INT(yX) - 1 'ELSE arbitraryLET baseFloor logarithm= INT(X)
330 END IF
PRINT "exp = "; EXP(x) ' exponential
340 END FUNCTION
PRINT "abs = "; ABS(-x) ' absolute value
</syntaxhighlight>
PRINT "floor = "; floor(x) ' floor
PRINT "ceil = "; ceiling(x) ' ceiling
PRINT "power = "; x ^ y ' power
END</syntaxhighlight>
 
==={{header|Applesoft BASIC}}===
Line 474 ⟶ 471:
280 PRINT "power = ";X^Y :REM power
290 END</syntaxhighlight>
 
==={{header|BASIC256}}===
<syntaxhighlight lang="basic256">e = exp(1) # e not available
print "e = "; e
print "PI = "; PI
 
x = 12.345
y = 1.23
 
print "sqrt = "; sqr(x) # square root
print "ln = "; log(e) # natural logarithm base e
print "log10 = "; log10(e) # base 10 logarithm
print "log = "; log(x)/log(y) # arbitrary base logarithm
print "exp = "; exp(e) # exponential
print "abs = "; abs(-1) # absolute value
print "floor = "; floor(-e) # floor
print "ceil = "; ceil(-e) # ceiling
print "power = "; x ^ y # power</syntaxhighlight>
{{out}}
<pre>e = 2.71828182846
PI = 3.14159265359
sqrt = 3.51354521815
ln = 1.0
log10 = 0.4342944819
log = 12.1404787425
exp = 15.1542622415
abs = 1
floor = -3
ceil = -2
power = 22.0056421324</pre>
 
==={{header|BBC BASIC}}===
<syntaxhighlight lang="bbcbasic"> e = EXP(1)
Pi = PI
Sqr2 = SQR(2)
Ln2 = LN(2)
Log2 = LOG(2) : REM Base 10
Exp2 = EXP(2)
Abs2 = ABS(-2)
Floor = INT(1.234)
Ceil = FNceil(1.234)
Power = 1.23^4
END
DEF FNceil(n) = INT(n) - (INT(n) <> n)
</syntaxhighlight>
 
==={{header|Chipmunk Basic}}===
Line 495 ⟶ 538:
260 if x < 0 then print int(x) else print int(x)+1
270 end sub</syntaxhighlight>
 
==={{header|FreeBASIC}}===
<syntaxhighlight lang="freebasic">' FB 1.05.0 Win64
 
#Include "crt/math.bi"
 
Print M_E '' constant "e" from C runtime library
Print M_PI '' constant "pi" from C runtime library
Print Sqr(2) '' square root function built into FB
Print Log(M_E) '' log to base "e" built into FB
Print log10(10) '' log to base 10 from C runtime library
Print Exp(1) '' exponential function built into FB
Print Abs(-1) '' absolute value function (integers or floats) built into FB
Print Int(-2.5) '' floor function built into FB
Print ceil(-2.5) '' ceiling function from C runtime library
Print 2.5 ^ 3.5 '' exponentiation operator built into FB
Sleep </syntaxhighlight>
{{out}}
<pre>
2.718281828459045
3.141592653589793
1.414213562373095
1
1
2.718281828459045
1
-3
-2
24.70529422006547
</pre>
 
==={{header|FutureBasic}}===
<syntaxhighlight lang="futurebasic">window 1
 
text ,,,,, 60// set tab width
 
print @"exp:", exp(1)
print @"pi:", pi
print @"sqr:", sqr(2)
print @"log:", log(2)
print @"log2:", log2(2)
print @"log10", log10(2)
print @"abs:", abs(-2)
print @"floor:", int(1.534)
print @"ceil:", val( using"###"; 1.534 )
print @"power:", 1.23 ^ 4
 
HandleEvents</syntaxhighlight>
Output:
<pre>
exp: 2.7182818285
pi: 3.1415926536
sqr: 1.4142135624
log: 0.6931471806
log2: 1
log10 0.3010299957
abs: 2
floor: 2
ceil: 2
power: 2.28886641
</pre>
 
==={{header|Gambas}}===
Line 539 ⟶ 643:
240 PRINT "power = "; X ^Y ' power
250 END</syntaxhighlight>
 
==={{header|IS-BASIC}}===
<syntaxhighlight lang="is-basic">100 LET X=2:LET Y=5
110 PRINT EXP(1) ! value of e
120 PRINT PI ! value of Pi
130 PRINT ROUND(PI,3) ! rounds Pi to 3 decimal places
140 PRINT TRUNCATE(PI,3) ! cuts 3 decimal places from Pi
150 PRINT SQR(X) ! square root of x
160 PRINT LOG(X) ! the natural logarithm of number x
170 PRINT LOG2(X) ! logarithm of x to base 2
180 PRINT LOG10(X) ! logarithm of x to base 10
190 PRINT EXP(X) ! exponential
200 PRINT ABS(X) ! the absolute value of a number
210 PRINT INT(X) ! the largest whole number not bigger than x
220 PRINT IP(X) ! the integer part of x
230 PRINT FP(X) ! stands for fractorial part
240 PRINT CEIL(X) ! ceiling: gives the smallest whole number not less than x
250 PRINT X^Y ! power
260 PRINT MIN(X,Y) ! the smaller number of x and y
270 PRINT MAX(X,Y) ! the bigger number of x and y
280 PRINT EPS(X) ! the smallest quantity that can be added to or subtracted from x to make the interpreter register a change in the value of x
290 PRINT INF ! The largest positive number the tinterpreter can handle. This number is 9.999999999*10^62</syntaxhighlight>
 
==={{header|Liberty BASIC}}===
{{works with|Just BASIC}}
Ceiling and floor easily implemented as functions.
<br>
sqr( is the LB function for square root.
<br>
e & pi not available- calculate as shown.
<syntaxhighlight lang="lb">
print exp(1) ' e not available
print 4 *atn(1) ' pi not available
 
x =12.345: y =1.23
 
print sqr(x), x^0.5 ' square root- NB the unusual name
print log(x) ' natural logarithm base e
print log(x) /2.303 ' base 10 logarithm
print log(x) / log(y) ' arbitrary base logarithm
print exp(x) ' exponential
print abs(x) ' absolute value
print floor(x) ' floor
print ceiling(x) ' ceiling
print x^y ' power
end
 
function floor(x)
if x >0 then
floor =int(x)
else
if x <>int(x) then floor =int(x) -1 else floor =int(x)
end if
end function
 
function ceiling(x)
if x <0 then
ceiling =int(x)
else
ceiling =int(x) +1
end if
end function
</syntaxhighlight>
 
==={{header|MSX Basic}}===
Line 563 ⟶ 730:
</syntaxhighlight>
 
==={{header|XBasicPureBasic}}===
<syntaxhighlight lang="purebasic">Debug #E
{{works with|Windows XBasic}}
Debug #PI
<syntaxhighlight lang="qbasic">PROGRAM "progname"
Debug Sqr(f)
VERSION "0.0000"
Debug Log(f)
Debug Exp(f)
Debug Log10(f)
Debug Abs(f)
Debug Pow(f,f)</syntaxhighlight>
 
==={{header|QBasic}}===
IMPORT "xma"
{{works with|QBasic|1.1}}
{{works with|QuickBasic|4.5}}
<syntaxhighlight lang="qbasic">'ceiling and floor easily implemented as functions.
'e & pi not available- calculate as shown.
 
DECLARE FUNCTION Entryceiling (x)
IF x < 0 THEN ceiling = INT(x) ELSE ceiling = INT(x) + 1
DECLARE FUNCTION Ceil (x)
DECLARE FUNCTION Floor (x)
 
FUNCTION Entry ()
DOUBLE e, pi, x, y
 
e = EXP(1)
PRINT "e = "; e ' e not available
pi = 4 * ATAN(1)
PRINT "pi = "; pi ' pi not available
 
x = 12.345
y = 1.23
 
PRINT "sqrt = "; SQRT (x) ' square root
PRINT "ln = "; LOG (x) ' natural logarithm base e
PRINT "log10 = "; LOG10 (x) ' base 10 logarithm
PRINT "log = "; LOG (x) / LOG (y) ' arbitrary base logarithm
PRINT "exp = "; EXP (x) ' exponential
PRINT "abs = "; ABS (-x) ' absolute value
PRINT "Floor = "; Floor (x) ' Floor easily implemented as functions
PRINT "Ceil = "; Ceil (x) ' Ceil easily implemented as functions
PRINT "power = "; x ** y ' power
END FUNCTION
 
FUNCTION Ceilfloor (x)
IF x < 0 THEN RETURN INT(x) ELSE RETURN INT(x) + 1
END FUNCTION
 
FUNCTION Floor (x)
IF x > 0 THEN
RETURN floor = INT(x)
ELSE
IF x <> INT(x) THEN RETURNfloor = INT(x) - 1 ELSE RETURNfloor = INT(x)
END IF
END FUNCTION
END PROGRAM
</syntaxhighlight>
 
PRINT "e = "; EXP(1) ' e not available
==={{header|IS-BASIC}}===
PRINT "PI = "; 4 * ATN(1) ' pi not available
<syntaxhighlight lang="is-basic">100 LET X=2:LET Y=5
110 PRINT EXP(1) ! value of e
x = 12.345: y = 1.23
120 PRINT PI ! value of Pi
130 PRINT ROUND(PI,3) ! rounds Pi to 3 decimal places
PRINT "sqrt = "; SQR(x), x ^ .5 ' square root- NB the unusual name
140 PRINT TRUNCATE(PI,3) ! cuts 3 decimal places from Pi
150 PRINT SQR"ln = "; LOG(Xx) ! square root of' xnatural logarithm base e
160 PRINT "log10 = "; LOG(Xx) / 2.303 ' base ! the natural10 logarithm of number x
170 PRINT LOG2(X)"log = "; LOG(x) / LOG(y) ! logarithm of' x toarbitrary base 2logarithm
180 PRINT LOG10"exp = "; EXP(Xx) ! logarithm of x to base' 10exponential
190 PRINT EXP"abs = "; ABS(X-x) ! exponential ' absolute value
200 PRINT ABS(X) "floor = "; floor(x) ! the absolute value of a' numberfloor
210 PRINT INT(X)"ceil = "; ceiling(x) ! the largest whole' number not bigger than xceiling
220 PRINT IP(X)"power = "; x ^ y ! the integer part of x ' power
END</syntaxhighlight>
230 PRINT FP(X) ! stands for fractorial part
 
240 PRINT CEIL(X) ! ceiling: gives the smallest whole number not less than x
==={{header|Run BASIC}}===
250 PRINT X^Y ! power
{{works with|Just BASIC}}
260 PRINT MIN(X,Y) ! the smaller number of x and y
<syntaxhighlight lang="runbasic">print "exp:";chr$(9); EXP(1)
270 PRINT MAX(X,Y) ! the bigger number of x and y
print "PI:";chr$(9); 4 * ATN(1)
280 PRINT EPS(X) ! the smallest quantity that can be added to or subtracted from x to make the interpreter register a change in the value of x
print "Sqr2:";chr$(9); SQR(2)
290 PRINT INF ! The largest positive number the tinterpreter can handle. This number is 9.999999999*10^62</syntaxhighlight>
print "Log2:";chr$(9); LOG(2) : REM Base 10
print "Exp2:";chr$(9); EXP(2)
print "Abs2:";chr$(9); ABS(-2)
print "Floor:";chr$(9); INT(1.534)
print "ceil:";chr$(9); val(using("###",1.534))
print "Power:";chr$(9); 1.23^4</syntaxhighlight>
<pre>exp: 2.71828183
PI: 3.14285707
Sqr2: 1.41421356
Log2: 0.693147181
Exp2: 7.3890561
Abs2: 2
Floor: 1
ceil: 2
Power: 2.28886641</pre>
 
==={{header|Sinclair ZX81 BASIC}}===
Line 664 ⟶ 827:
NB. Both <math>x</math> and <math>y</math> can be real numbers.
 
==={{header|BBCTI-89 BASIC}}===
{|
<syntaxhighlight lang="bbcbasic"> e = EXP(1)
|-
Pi = PI
! Mathematical !! TI-89 !! Notes
Sqr2 = SQR(2)
|-
Ln2 = LN(2)
| <math>e </math> || <code style="font-family:'TI Uni'">ℯ </code> || (U+212F SCRIPT SMALL E)
Log2 = LOG(2) : REM Base 10
|-
Exp2 = EXP(2)
| <math>\pi </math> || <code style="font-family:'TI Uni'">π </code> || (U+03C0 GREEK SMALL LETTER PI)
Abs2 = ABS(-2)
|-
Floor = INT(1.234)
| <math>\sqrt{x} </math> || <code style="font-family:'TI Uni'">√(x) </code> || (U+221A SQUARE ROOT)
Ceil = FNceil(1.234)
|-
Power = 1.23^4
| <math>\log_e(x) </math> || <code style="font-family:'TI Uni'">ln(x) </code>
END
|-
| <math>\log_{10}(x) </math> || <code style="font-family:'TI Uni'">log(x) </code>
DEF FNceil(n) = INT(n) - (INT(n) <> n)
|-
</syntaxhighlight>
| <math>\log_b(x) </math> || <code style="font-family:'TI Uni'">log(b, x) </code> || The optional base argument comes ''first''
|-
| <math>\lfloor x\rfloor</math> || <code style="font-family:'TI Uni'">floor(x) </code>
|-
| <math>\lceil x\rceil </math> || <code style="font-family:'TI Uni'">ceiling(x)</code>
|-
| <math>x^y </math> || <code style="font-family:'TI Uni'">x^y </code>
|}
 
==={{header|True BASIC}}===
{{works with|Decimal BASIC}}
<syntaxhighlight lang="qbasic">FUNCTION floor(x)
IF x > 0 THEN
LET floor = INT(x)
ELSE
IF x <> INT(x) THEN LET floor = INT(x) - 1 ELSE LET floor = INT(x)
END IF
END FUNCTION
 
PRINT "e = "; exp(1) ! e not available
=={{header|BASIC256}}==
PRINT "PI = "; PI
<syntaxhighlight lang="basic256">e = exp(1) # e not available
print "e = "; e
print "PI = "; PI
 
LET x = 12.345
LET y = 1.23
 
PRINT "sqrt = "; SQR(x), x^0.5 ! square root- NB the unusual name
PRINT "ln = "; LOG(x) ! natural logarithm base e
PRINT "log2 = "; LOG2(x) ! base 2 logarithm
PRINT "log10 = "; LOG10(x) ! base 10 logarithm
PRINT "log = "; LOG(x)/LOG(y) ! arbitrary base logarithm
PRINT "exp = "; EXP(x) ! exponential
PRINT "abs = "; ABS(-1) ! absolute value
PRINT "floor = "; floor(x) ! floor easily implemented as functions
PRINT "ceil = "; CEIL(x) ! ceiling
PRINT "power = "; x ^ y ! power
END</syntaxhighlight>
 
==={{header|XBasic}}===
{{works with|Windows XBasic}}
<syntaxhighlight lang="qbasic">PROGRAM "realcaf"
VERSION "0.0000"
 
IMPORT "xma"
 
DECLARE FUNCTION Entry ()
DECLARE FUNCTION Ceil (x)
DECLARE FUNCTION Floor (x)
 
FUNCTION Entry ()
DOUBLE e, pi, x, y
e = EXP(1)
PRINT "e = "; e ' e not available
pi = 4 * ATAN(1)
PRINT "pi = "; pi ' pi not available
x = 12.345
y = 1.23
PRINT "sqrt = "; SQRT (x) ' square root
PRINT "ln = "; LOG (x) ' natural logarithm base e
PRINT "log10 = "; LOG10 (x) ' base 10 logarithm
PRINT "log = "; LOG (x) / LOG (y) ' arbitrary base logarithm
PRINT "exp = "; EXP (x) ' exponential
PRINT "abs = "; ABS (-x) ' absolute value
PRINT "Floor = "; Floor (x) ' Floor easily implemented as functions
PRINT "Ceil = "; Ceil (x) ' Ceil easily implemented as functions
PRINT "power = "; x ** y ' power
END FUNCTION
 
FUNCTION Ceil (x)
IF x < 0 THEN RETURN INT(x) ELSE RETURN INT(x) + 1
END FUNCTION
 
FUNCTION Floor (x)
IF x > 0 THEN
RETURN INT(x)
ELSE
IF x <> INT(x) THEN RETURN INT(x) - 1 ELSE RETURN INT(x)
END IF
END FUNCTION
END PROGRAM
</syntaxhighlight>
 
==={{header|Yabasic}}===
<syntaxhighlight lang="yabasic">print "e = ", euler
print "pi = ", pi
x = 12.345
y = 1.23
 
print "sqrt = ";, sqrsqrt(x2) # // square root
print "ln = ";, log(eeuler) # // natural logarithm base e
print "log10log = ";, log10log(ex, y) // #arbitrary base 10y logarithm
print "logexp = ";, logexp(xeuler)/log(y) # arbitrary base logarithm // exponential
print "expabs = ";, expabs(e-1) # exponential // absolute value
print "abs floor = ";, absfloor(-1euler) # absolute// valuefloor
print "floorceil = ";, floorceil(-eeuler) # floor // ceiling
print "ceil power = ";, ceil(-e)x ^ y, " ", x ** y #// ceilingpower
print "power = "; x ^ y # powerend</syntaxhighlight>
{{out}}
<pre>e = 2.7182818284671828
PIpi = 3.1415926535914159
sqrt = 31.5135452181541421
ln = 1.0
log = 12.1405
log10 = 0.4342944819
logexp = 1215.14047874251543
exp = 15.1542622415
abs = 1
floor = -3
ceil = -2
power = 22.00564213240056 22.0056</pre>
 
=={{header|bc}}==
Line 1,107 ⟶ 1,348:
 
=={{header|EasyLang}}==
EasyLang does not have ''e'', exponential, or a ceiling function.
<syntaxhighlight lang="easylang">
# e is not available
x = 1.5
# pi
# calculate e
print pi
e = pow 3 (1 / logn 3)
numfmt 4 0
# e
print e
# square root
print sqrt x2
# natural logarithm base 10
print lognlog10 x1000
# exponential is not available
print pow e x
# absolute value
print abs x-20
# floor
print floor x1.5
# ceiling is not available
if x > floor x
print floor x + 1
else
print x
end
# power
print pow 2 x10
</syntaxhighlight>
 
Line 1,363 ⟶ 1,594:
 
The 4 need not be named as 4.0, or 4D0, as 4 the integer will be converted by the compiler to double precision, because it is to meet a known double precision value in simple multiplication and so will be promoted. Hopefully, at compile time.
 
=={{header|FreeBASIC}}==
<syntaxhighlight lang="freebasic">' FB 1.05.0 Win64
 
#Include "crt/math.bi"
 
Print M_E '' constant "e" from C runtime library
Print M_PI '' constant "pi" from C runtime library
Print Sqr(2) '' square root function built into FB
Print Log(M_E) '' log to base "e" built into FB
Print log10(10) '' log to base 10 from C runtime library
Print Exp(1) '' exponential function built into FB
Print Abs(-1) '' absolute value function (integers or floats) built into FB
Print Int(-2.5) '' floor function built into FB
Print ceil(-2.5) '' ceiling function from C runtime library
Print 2.5 ^ 3.5 '' exponentiation operator built into FB
Sleep </syntaxhighlight>
 
{{out}}
<pre>
2.718281828459045
3.141592653589793
1.414213562373095
1
1
2.718281828459045
1
-3
-2
24.70529422006547
</pre>
 
=={{header|Free Pascal}}==
Line 1,412 ⟶ 1,612:
x^y
</syntaxhighlight>
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">window 1
 
text ,,,,, 60// set tab width
 
print @"exp:", exp(1)
print @"pi:", pi
print @"sqr:", sqr(2)
print @"log:", log(2)
print @"log2:", log2(2)
print @"log10", log10(2)
print @"abs:", abs(-2)
print @"floor:", int(1.534)
print @"ceil:", val( using"###"; 1.534 )
print @"power:", 1.23 ^ 4
 
HandleEvents</syntaxhighlight>
Output:
<pre>
exp: 2.7182818285
pi: 3.1415926536
sqr: 1.4142135624
log: 0.6931471806
log2: 1
log10 0.3010299957
abs: 2
floor: 2
ceil: 2
power: 2.28886641
</pre>
 
=={{header|Go}}==
Line 1,806 ⟶ 1,975:
1.64->ceil
1.64->pow(10.0)</syntaxhighlight>
 
=={{header|Liberty BASIC}}==
Ceiling and floor easily implemented as functions.
<br>
sqr( is the LB function for square root.
<br>
e & pi not available- calculate as shown.
<syntaxhighlight lang="lb">
print exp( 1) ' e not available
print 4 *atn( 1) ' pi not available
 
x =12.345: y =1.23
 
print sqr( x), x^0.5 ' square root- NB the unusual name
print log( x) ' natural logarithm base e
print log( x) /2.303 ' base 10 logarithm
print log( x) /log( y) ' arbitrary base logarithm
print exp( x) ' exponential
print abs( x) ' absolute value
print floor( x) ' floor
print ceiling( x) ' ceiling
print x^y ' power
 
end
 
function floor( x)
if x >0 then
floor =int( x)
else
if x <>int( x) then floor =int( x) -1 else floor =int( x)
end if
end function
 
function ceiling( x)
if x <0 then
ceiling =int( x)
else
ceiling =int( x) +1
end if
end function
</syntaxhighlight>
 
=={{header|Lingo}}==
Line 2,726 ⟶ 2,854:
Write-Host ([Math]::Ceiling(3.14))
Write-Host ([Math]::Pow(2, 3))</syntaxhighlight>
 
=={{header|PureBasic}}==
<syntaxhighlight lang="purebasic">Debug #E
Debug #PI
Debug Sqr(f)
Debug Log(f)
Debug Exp(f)
Debug Log10(f)
Debug Abs(f)
Debug Pow(f,f)</syntaxhighlight>
 
=={{header|Python}}==
Line 3,098 ⟶ 3,216:
exp(x) #exponential
</syntaxhighlight>
 
=={{header|Run BASIC}}==
<syntaxhighlight lang="runbasic">print "exp:";chr$(9); EXP(1)
print "PI:";chr$(9); 22/7
print "Sqr2:";chr$(9); SQR(2)
print "Log2:";chr$(9); LOG(2) : REM Base 10
print "Exp2:";chr$(9); EXP(2)
print "Abs2:";chr$(9); ABS(-2)
print "Floor:";chr$(9); INT(1.534)
print "ceil:";chr$(9); val(using("###",1.534))
print "Power:";chr$(9); 1.23^4</syntaxhighlight>
<pre>exp: 2.71828183
PI: 3.14285707
Sqr2: 1.41421356
Log2: 0.693147181
Exp2: 7.3890561
Abs2: 2
Floor: 1
ceil: 2
Power: 2.28886641</pre>
 
=={{header|Rust}}==
Line 3,320 ⟶ 3,418:
math::constants::constants e pi
puts "e = $e, pi = $pi"</syntaxhighlight>
 
=={{header|TI-89 BASIC}}==
{|
|-
! Mathematical !! TI-89 !! Notes
|-
| <math>e </math> || <code style="font-family:'TI Uni'">ℯ </code> || (U+212F SCRIPT SMALL E)
|-
| <math>\pi </math> || <code style="font-family:'TI Uni'">π </code> || (U+03C0 GREEK SMALL LETTER PI)
|-
| <math>\sqrt{x} </math> || <code style="font-family:'TI Uni'">√(x) </code> || (U+221A SQUARE ROOT)
|-
| <math>\log_e(x) </math> || <code style="font-family:'TI Uni'">ln(x) </code>
|-
| <math>\log_{10}(x) </math> || <code style="font-family:'TI Uni'">log(x) </code>
|-
| <math>\log_b(x) </math> || <code style="font-family:'TI Uni'">log(b, x) </code> || The optional base argument comes ''first''
|-
| <math>\lfloor x\rfloor</math> || <code style="font-family:'TI Uni'">floor(x) </code>
|-
| <math>\lceil x\rceil </math> || <code style="font-family:'TI Uni'">ceiling(x)</code>
|-
| <math>x^y </math> || <code style="font-family:'TI Uni'">x^y </code>
|}
 
=={{header|True BASIC}}==
<syntaxhighlight lang="qbasic">FUNCTION floor(x)
IF x > 0 THEN
LET floor = INT(x)
ELSE
IF x <> INT(x) THEN LET floor = INT(x) - 1 ELSE LET floor = INT(x)
END IF
END FUNCTION
 
PRINT "e = "; exp(1) ! e not available
PRINT "PI = "; PI
 
LET x = 12.345
LET y = 1.23
 
PRINT "sqrt = "; SQR(x), x^0.5 ! square root- NB the unusual name
PRINT "ln = "; LOG(x) ! natural logarithm base e
PRINT "log2 = "; LOG2(x) ! base 2 logarithm
PRINT "log10 = "; LOG10(x) ! base 10 logarithm
PRINT "log = "; LOG(x)/LOG(y) ! arbitrary base logarithm
PRINT "exp = "; EXP(x) ! exponential
PRINT "abs = "; ABS(-1) ! absolute value
PRINT "floor = "; floor(x) ! floor easily implemented as functions
PRINT "ceil = "; CEIL(x) ! ceiling
PRINT "power = "; x ^ y ! power
END</syntaxhighlight>
 
=={{header|UNIX Shell}}==
Line 3,424 ⟶ 3,471:
 
=={{header|Wren}}==
<syntaxhighlight lang="ecmascriptwren">var e = 1.exp
 
System.print("e = %(e)")
Line 3,495 ⟶ 3,542:
4.0000000000000000
</pre>
 
=={{header|Yabasic}}==
<syntaxhighlight lang="yabasic">print "e = ", euler
print "pi = ", pi
x = 12.345
y = 1.23
print "sqrt = ", sqrt(2) // square root
print "ln = ", log(euler) // natural logarithm base e
print "log = ", log(x, y) // arbitrary base y logarithm
print "exp = ", exp(euler) // exponential
print "abs = ", abs(-1) // absolute value
print "floor = ", floor(-euler) // floor
print "ceil = ", ceil(-euler) // ceiling
print "power = ", x ^ y, " ", x ** y // power
end</syntaxhighlight>
{{out}}
<pre>e = 2.71828
pi = 3.14159
sqrt = 1.41421
ln = 1
log = 12.1405
exp = 15.1543
abs = 1
floor = -3
ceil = -2
power = 22.0056 22.0056</pre>
 
=={{header|Zig}}==
511

edits