Function
Meaning
Int
The function that converts a number into an integer Sqr
computes the square root of a number Abs
function that returns the absolute value of a number. Exp
Exp= ex. For example, Exp(1)=e1 = 2.7182818284590 Fix
Fix and Int are the same if the number is a positive number as both truncate the decimal part of the number and return an integer. However, when the number is negative, it will return the smallest integer that is larger than the number. For example, Fix(-6.34)= -6 while Int(-6.34)=-7. Round
Round is the function that rounds up a number to a certain number of decimal places. The Format is Round (n, m) which means to round a number n to m decimal places. For example, Round (7.2567, 2) =7.26 Sin Computes the value of sine of an angle in radian. Cos Computes the value of Cosine of an angle in radian. Tan Computes the value of Tangent of an angle in radian Atn Computes the value of Arc tangent of an angle in radian This example computes the values of Int(x), Fix(x) and Round(x,n) in a table form. It uses the Do Loop statement and the Rnd function to generate 10 numbers. The statement x = Round (Rnd * 7, 7) rounds a random number between 0 and 7 to 7 decimal places. Using commas in between items will create spaces between them and hence a table of values can be created. The program is shown below and
the output is displayed in Figure 12.3
Private Sub Form_Activate ()
n = 1
Print " n", " x", "Int(x)", "Fix(x)", "Round(x, 4)"
Do While n < 11
Randomize Timer
x = Round (Rnd * 7, 7)
Print n, x, Int(x), Fix(x), Round(x, 4)
n = n + 1
Loop
End Sub
The output is shown below: