Numeric / Mathematical
Library Functions
A
numeric function is a function that processes upon the numeric data. When they are called, they return a single value that can be either an integer
or a single precision data type. Following are the different types of numeric
functions.
It is a mathematical function which display the number without integer.
Example:
CLS REM example of INT function PRINT INT(14.4) PRINT INT(-65.4) END |
Output |
SQR
It is used to obtain the square root of
an argument. The argument must contain positive expression.
Syntax: SQR (numeric
expression)
Example:
REM Example of SQR function CLS PRINT SQR(121) LET a = 9 PRINT SQR(a) END |
Output |
It is a math function that returns
the absolute value of a numeric expression. A number’s absolute is its value
without a “+” or”-“sign.(it also returns –ve number into +ve number)
Syntax: ABS(numeric
expression)
Example:
REM Example of ABS function. CLS PRINT ABS(67.8) PRINT ABS(-12.4) PRINT ABS(4 - 6) END |
|
CINT
This
statement converts a numeric expression to an integer by rounding the
fractional part of the expression.
Syntax:
CINT (Numeric expression)
Example:
REM Example of CINT function CLS PRINT CINT(23.545) PRINT CINT(23.234) END |
Output |
SGN
It
is a numeric function that indicates the sign of numeric expression.
If
the numeric expression is positive, it returns 1
If
the numeric expression is negative, it returns -1
If
the numeric expression is zero, it returns 0
Syntax:
SGN(numeric expression)
Example:
REM Example of SGN function CLS PRINT SGN(10) PRINT SGN(-10) PRINT SGN(0) END |
Output |
FIX
It
is a mathematical function that returns the integer part of a numeric
expression after remove decimal part.
Syntax:
FIX(numeric expression)
Example:
REM Example of FIX function CLS PRINT FIX(-34.67) PRINT FIX(21.78) END |
Output |
SIN,
COS and TAN
SIN
function gives sin, COS function gives cosine and TAN function gives tangent of
given angle.
Syntax:
SIN(angle)
COS(angle)
TAN(angle)
Example:
REM Example of SIN, COS and
SIN function. CLS PRINT SIN(45) PRINT COS(45) PRINT TAN(45) END |
Output |
EXP
This
function is used to calculate the exponential of given numeric expression. It
gives e raised to a given power, where e is the natural logarithm.
Syntax:
EXP(numeric expression)
Note:
Numeric expression which must be less than or equal to 88.02969
Example:
REM Example EXP function CLS PRINT EXP(0) PRINT EXP(4) END |
|
LOG
This
function gives the natural logarithm of the given numeric expression.
Syntax:
LOG(numeric expression)
Example:
REM Example of LOG function CLS PRINT LOG(1) PRINT LOG(4) END |
Output |
No comments:
Post a Comment