Real constants and functions: Difference between revisions

→‎{{header|BASIC}}: Added ANSI BASIC.
m (Dialects of BASIC moved to the BASIC section.)
(→‎{{header|BASIC}}: Added ANSI BASIC.)
Line 415:
 
=={{header|BASIC}}==
==={{header|ANSI BASIC}}===
{{trans|True BASIC|In fact, True BASIC implements ANSI BASIC, but adds some other features.}}
{{works with|Decimal BASIC}}
<syntaxhighlight lang="basic">
100 REM Real constants and functions
110 DECLARE EXTERNAL FUNCTION Floor
120 PRINT "e = "; EXP(1) ! e not available
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}}
Line 919 ⟶ 950:
ceil = -2
power = 22.0056 22.0056</pre>
 
 
=={{header|bc}}==
511

edits