6.3 Float function library
Name: Float
Note: This function library contains typical and commonly used floating point arithmetic programs.
int
Program: int(value)
Description: Return the integer part of the given value.
Parameters: value=number
Return value: integer or invalid
Exception: None
Example: var a =3.14;
var b =(a); //b=3
var c =(-2.8); //c=-2
floor
Program: floor(value)
Description: Return the integer value, as long as it is closest to the given value but cannot be greater than it.
If the value is already an integer, the result is the value itself.
Parameters: value=number
Return value: integer or invalid
Exception: None
Example: var a =3.14;
var b =(a); //b=3
var c =(-2.8); //c=-3
ceil
Program:ceil(value)
Description: Return an integer value that is closest to the given value but cannot be less than it.
If the value is already an integer, the result is the value itself.
Parameters: value=number
Return value: integer or invalid
Exception: None
Example: var a =3.14;
var b =(a); //b=4
var c =(-2.8); //c=-2
pow
Program: pow(x,y)
Description: Return the value of x to the y power.
If x is a negative number, y must be a positive number.
Parameters: x=number
y=number
Return value: floating point number or invalid
Exception: If x==0 and y<0, return invalid
If x<0 and y is not an integer, pass the invalid back
Example: var a = 3
var b =(a,2); //b=9
round
Program: round(value)
Description: Return the integer closest to the given value
If the two integer values are equal to the program with value, select a larger number.
If the value is already a positive number, the result is the value itself.
Parameters: value=number
Return value: integer or invalid
Exception: None
Example: var a=(3.5); // a=4
var b=(-3.5); //b=-3
var c=(0.5); // c=1
var d=(-0.5); //d=0
squt
Program: sqrt(value)
Description: Pass back the square root approximation given the value value.
Parameters: value=floating point number
Return value: floating point number or invalid
Exception: If the value is negative, the invalid is returned.
Example: var a=4;
var b=(a); //b=2.0
var c=(5); //c=2.2360679775
maxFloat
Program:maxFloat()
Description: Pass back the largest floating point value in the quasi-floating number format supported by IEEE 754.
Parameters: None
Return value: floating point number 3.40282347E+38
Exception: None
Example: var a=();
minFloat
Program: minFloat()
Description: Pass back the smallest floating point value in the quasi-floating number format supported by IEEE 754.
Parameters: None
Return value: floating point number 1.17549435E-38
Exception: None
Example: var a=();
Previous page123Next pageRead the full text