Liberty BASIC Help Online

Mathematical Operations
ABS( n )
Description:
This function returns  | n |  (the absolute value of n).  "n" can be a number or any numeric expression.
 
Usage:
 
print abs( -5 )      produces: 5
 
print abs( 6 - 13 )  produces: 7
 
print abs( 2 + 4 )   produces: 6
 
print abs( 3 )       produces: 3
 
print abs( 3/2 )     produces: 1.5
 
print abs( 5.75 )    produces:  5.75
 
SQR(n)
Description:
This function returns the square root of the number or numeric expressioin n.
 
Usage:
 
  print "The square root of 2 is: ";
  print SQR(2)
 
 
EXP( n )
Description:
This function returns e ^ n,   with e being 2.7182818 . . .
 
Usage:
 
  print exp( 5 )       produces:  148.41315
 
 
LOG( n )
Description:
This function returns the natural log of  n.
 
Usage:
 
  print log( 7 )              produces:  1.9459101
 
 
INT( n )
Description:
This function removes the fractional part of number, which is the part of the number after the decimal point, leaving only the whole number part behind.
 
Usage:
 
[retry]
  input "Enter an integer number>"; i
  if i<>int(i) then
        print i; " isn't an integer! Re-enter."
        goto [retry]
  end if
 
 
MAX( expr1, expr2 )
Description:
This function returns the greater of two numeric values.
 
Usage:
 
    input "Enter a number?"; a
    input "Enter another number?"; b
    print "The greater value is "; max(a, b)
 
MIN( expr1, expr2 )
Description:
This function returns the smaller of two numeric values.
 
Usage:
 
    input "Enter a number?"; a
    input "Enter another number?"; b
    print "The smaller value is "; min(a, b)
 
 
RND(number)
Description:
This function returns a random number between 0 and 1.  The number parameter is usually set to 1, but the value is unimportant because it is not actually used by the functoin.  The function will always return an arbitrary number between 0 and 1.
 
Usage:
 
  ' print ten numbers between one and ten
  for a = 1 to 10
      print int(rnd(1)*10) + 1
  next a
 
RANDOMIZE n
Description:
This function seeds the random number generator in a predictable way.  The seed numbers must be greater than 0 and less than 1.  Numbers such as 0.01 and 0.95 are used with RANDOMIZE.
 
Usage:
 
  'this will always produce the same 10 numbers
  randomize 0.5
  for x = 1 to 10
    print int(rnd(1)*100)
  next x


Copyright (C) 2003 Shoptalk Systems
Liberty BASIC - http://www.libertybasic.com/