Real constants and functions: Difference between revisions

→‎{{header|BASIC}}: Added ANSI BASIC.
(→‎{{header|BASIC}}: Added ANSI BASIC.)
(10 intermediate revisions by 7 users not shown)
Line 415:
 
=={{header|BASIC}}==
==={{header|ANSI BASIC}}===
{{works with|QuickBasic|4.5}}
{{trans|True BASIC|In fact, True BASIC implements ANSI BASIC, but adds some other features.}}
<syntaxhighlight lang="qbasic">abs(x) 'absolute value
{{works with|Decimal BASIC}}
sqr(x) 'square root
<syntaxhighlight lang="basic">
exp(x) 'exponential
100 REM Real constants and functions
log(x) 'natural logarithm
110 DECLARE EXTERNAL FUNCTION Floor
x ^ y 'power
'floor,120 ceiling,PRINT "e, and pi = "; EXP(1) ! e not available</syntaxhighlight>
130 PRINT "PI = "; PI
140 LET X = 12.345
150 LET Y = 1.23
160 PRINT "sqrt = "; SQR(X), X ^ 0.5 ! square root- NB the unusual name
170 PRINT "ln = "; LOG(X) ! natural logarithm base e
180 PRINT "log2 = "; LOG2(X) ! base 2 logarithm
190 PRINT "log10 = "; LOG10(X) ! base 10 logarithm
200 PRINT "log = "; LOG(X) / LOG(Y) ! arbitrary base logarithm
210 PRINT "exp = "; EXP(X) ! exponential
220 PRINT "abs = "; ABS(-1) ! absolute value
230 PRINT "floor = "; Floor(X) ! floor easily implemented as functions
240 PRINT "ceil = "; CEIL(X) ! ceiling
250 PRINT "power = "; X ^ Y ! power
260 END
270 REM **
280 EXTERNAL FUNCTION Floor(X)
290 IF X > 0 THEN
300 LET Floor = INT(X)
310 ELSE
320 IF X <> INT(X) THEN LET Floor = INT(X) - 1 ELSE LET Floor = INT(X)
330 END IF
340 END FUNCTION
</syntaxhighlight>
 
==={{header|Applesoft BASIC}}===
{{works with|Chipmunk Basic}}
{{works with|GW-BASIC}}
{{works with|MSX Basic}}
{{works with|QBasic}}
<syntaxhighlight lang="qbasic">100 HOME : REM 10 CLS for GW-BASIC or MSX Basic or QBasic
110 PRINT "e = ";EXP(1) :REM e not available
120 PRINT "PI = ";4 * ATN(1) :REM pi not available
130 X = 12.345
140 Y = 1.23
150 PRINT "sqrt = ";SQR(X) :REM square root
160 PRINT "ln = ";LOG(X) :REM natural logarithm base e
170 PRINT "log10 = ";LOG(X)/LOG(10) :REM base 10 logarithm
180 PRINT "log = ";LOG(X)/LOG(Y) :REM arbitrary base logarithm
190 PRINT "exp = ";EXP(X) :REM exponential
200 PRINT "abs = ";ABS(-X) :REM absolute value
210 PRINT "floor = "; :REM floor not available
220 IF X > 0 THEN PRINT INT(X)
230 IF X <= 0 AND X <> INT(X) THEN PRINT INT(X)-1
240 IF X <= 0 AND X = INT(X) THEN PRINT INT(X)
250 PRINT "ceil = "; :REM ceil not available
260 IF X < 0 THEN PRINT INT(X)
270 IF X >= 0 THEN PRINT INT(X)+1
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}}===
{{works with|Chipmunk Basic|3.6.4}}
<syntaxhighlight lang="qbasic">100 cls
110 print "e = ";exp(1)' e not available
120 print "PI = ";4*arctan(1)' pi not available
130 x = 12.345
140 y = 1.23
150 print "sqrt = ";sqr(x)' square root
160 print "ln = ";log(x)' natural logarithm base e
170 print "log10 = ";log(x)/log(10)' base 10 logarithm
180 print "log = ";log(x)/log(y)' arbitrary base logarithm
190 print "exp = ";exp(x)' exponential
200 print "abs = ";abs(-x)' absolute value
210 print "floor = ";floor(x)' floor
220 print "ceil = "; : ceil(x)' ceil easily implemented as function
230 print "power = ";x^y ' power
240 end
250 sub ceil(x)
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}}===
<syntaxhighlight lang="vbnet">Public Sub Main()
Dim e As Float = Exp(1)
Print "e = "; e ' e not available
Print "π = "; Pi ' pi
Dim x As Float = 12.345
Dim y As Float = 1.23
Print "sqrt = "; Sqr(x)' square root
Print "ln = "; Log(x)' natural logarithm base e
Print "log10 = "; Log(x) / Log(10) ' 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
Print "ceil = "; Ceil(x)' ceil
Print "power = "; x ^ y ' power
End</syntaxhighlight>
 
==={{header|GW-BASIC}}===
{{works with|BASICA}}
{{works with|Chipmunk Basic}}
{{works with|MSX_BASIC}}
{{works with|QBasic}}
{{works with|PC-BASIC|any}}
<syntaxhighlight lang="qbasic">100 CLS
110 PRINT "e = "; EXP(1) ' e not available
120 PRINT "PI = "; 4 * ATN(1) ' pi not available
130 X = 12.345
140 Y = 1.23
150 PRINT "sqrt = "; SQR(X) ' square root
160 PRINT "ln = "; LOG(X) ' natural logarithm base e
170 PRINT "log10 = "; LOG(X)/LOG(10) ' base 10 logarithm
180 PRINT "log = "; LOG(X)/LOG(Y) ' arbitrary base logarithm
190 PRINT "exp = "; EXP(X) ' exponential
200 PRINT "abs = "; ABS(-X) ' absolute value
210 PRINT "floor = "; floor(X) ' floor
220 PRINT "ceil = "; : ' ceil not available
230 IF X < 0 THEN PRINT INT(X) ELSE PRINT INT(X)+1
240 PRINT "power = "; X ^Y ' power
250 END</syntaxhighlight>
 
==={{header|IS-BASIC}}===
Line 444 ⟶ 665:
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}}===
{{works with|MSX Basic|any}}
{{works with|Chipmunk Basic}}
<syntaxhighlight lang="qbasic">100 CLS
110 E = EXP(1)
120 PRINT "e = "; E ' e not available
130 PI = 4 * ATN(1)
140 PRINT "PI = "; PI ' pi not available
150 X = 12.345
160 Y = 1.23
170 PRINT "sqrt = "; SQR(X) ' square root
180 PRINT "ln = "; LOG(X) ' natural logarithm base e
190 PRINT "log10 = "; LOG(X)/LOG(10) ' base 10 logarithm
200 PRINT "log = "; LOG(X)/LOG(Y) ' arbitrary base logarithm
210 PRINT "exp = "; EXP(X) ' exponential
220 PRINT "abs = "; ABS(-X) ' absolute value
230 PRINT "floor = "; floor(X) ' floor
240 PRINT "ceil = "; : ' ceil not available
250 IF X < 0 THEN PRINT INT(X) ELSE PRINT INT(X)+1
260 PRINT "power = "; X ^Y ' power
270 END
</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|QBasic}}===
{{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.
 
FUNCTION ceiling (x)
IF x < 0 THEN ceiling = INT(x) ELSE ceiling = INT(x) + 1
END FUNCTION
 
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
 
PRINT "e = "; EXP(1) ' e not available
PRINT "PI = "; 4 * ATN(1) ' pi not available
x = 12.345: y = 1.23
PRINT "sqrt = "; SQR(x), x ^ .5 ' square root- NB the unusual name
PRINT "ln = "; LOG(x) ' natural logarithm base e
PRINT "log10 = "; LOG(x) / 2.303 ' 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
PRINT "ceil = "; ceiling(x) ' ceiling
PRINT "power = "; x ^ y ' power
END</syntaxhighlight>
 
==={{header|Run BASIC}}===
{{works with|Just BASIC}}
<syntaxhighlight lang="runbasic">print "exp:";chr$(9); EXP(1)
print "PI:";chr$(9); 4 * ATN(1)
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|Sinclair ZX81 BASIC}}===
Line 477 ⟶ 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|BASIC256True BASIC}}===
{{works with|Decimal BASIC}}
<syntaxhighlight lang="basic256">e = exp(1) # e not available
<syntaxhighlight lang="qbasic">FUNCTION floor(x)
print "e = "; e
print "PI IF =x ";> PI0 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|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 920 ⟶ 1,348:
 
=={{header|EasyLang}}==
EasyLang does not have ''e'', exponential, or a ceiling function.
<syntaxhighlight lang="easylang">
# e is not available
pi # Pi
# pi
sqrt x # Square root
print pi
logn x # Natural logarithm (base e)
# square root
abs x # Absolute value
print sqrt 2
floor x # Floor
# logarithm base 10
pow x y # Power
print log10 1000
# exponential is not available
# absolute value
print abs -20
# floor
print floor 1.5
# ceiling is not available
# power
print pow 2 10
</syntaxhighlight>
 
Line 1,158 ⟶ 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,207 ⟶ 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,601 ⟶ 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,449 ⟶ 2,782:
y = gamma (x);
y = loggamma (x);</syntaxhighlight>
 
=={{header|Plain English}}==
Plain English comes with these constants and functions in the noodle (Euler's number, logarithms, exponential, ceiling, and floor are not available):
<syntaxhighlight lang="text">
The pizza pie is a fraction equal to 355/113. \ equivalent to pi
 
\ square root
To find a square root of a number: \ rounds down
Privatize the number.
De-sign the number.
If the number is 0, put 0 into the square root; exit.
If the number is 1, put 1 into the square root; exit.
Put 1 into a square number.
Put 3 into a delta number.
Loop.
If the square is greater than the number, break.
Add the delta to the square.
Add 2 to the delta.
Repeat.
Put the delta divided by 2 minus 1 into the square root.
 
A square root is a number.
 
\ absolute value
To put a fraction's absolute value into another fraction:
Put the fraction into the other fraction.
De-sign the other fraction.
 
To put a number's absolute value into another number:
Put the number into the other number.
De-sign the other number.
 
To put a pair's absolute value into another pair:
Put the pair into the other pair.
De-sign the other pair.
 
\ power
To raise a number to another number:
If the other number is 0, put 1 into the number; exit.
If the other number is less than 0, put 0 into the number; exit. \ should be 1/the raised result, but always comes out 0 with numbers
Put 1 into a result number.
Loop.
If a counter is past the other number, break.
Multiply the result by the number.
Repeat.
Put the result into the number.
</syntaxhighlight>
 
=={{header|Pop11}}==
Line 2,474 ⟶ 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 2,799 ⟶ 3,169:
>> x .^ 2
25</syntaxhighlight>
 
=={{header|RPL}}==
{| class="wikitable"
! RPL code
! Comment
|-
|
'''e'''
'''π'''
x '''√'''
x '''LN'''
x '''LNP'''
x '''LOG'''
x '''EXP'''
x '''ABS'''
x '''FLOOR'''
x '''CEIL'''
x y '''^'''
|
e
π
square root
logarithm (base e)
equivalent to x 1 + LN - e.g. Log(x+1) - but more accurate for small values of x
logarithm (base 10)
exponential
absolute value
floor
ceiling
power
|}
 
=={{header|Ruby}}==
Line 2,815 ⟶ 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,037 ⟶ 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,141 ⟶ 3,471:
 
=={{header|Wren}}==
<syntaxhighlight lang="ecmascriptwren">var e = 1.exp
 
System.print("e = %(e)")
Line 3,212 ⟶ 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