Home | About SQeeL | Document | DownLoad | Mail Japanese
Home > Document > SQeeL Reference

Numeric function

  • Built-in function
  • avg()
    Description
    Returns the average value of array variable
    Syntax
    ret = avg(array)
    Parameters
    array:Array to determine the average
    Return Value
    real number:Result
    0:Error or result
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    //[result example]
    //
    // Average is 11.000000
    // 
    
    exit Run()
    
    function Run()
    
    	local arr[3] = {18, 9, 6}
    	local avg_arr
    
    	avg_arr = avg(arr)
    
    	print('Average is ${avg_arr}', stdout)
    
    endfunction
    
    
    Topへ
    ceil()
    Description
    Returns the smallest value that is greater than or equal to an actual count
    Syntax
    ret = ceil(n)
    Parameters
    n:
    Return Value
    real number:Result
    0:Error or result
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    //[result example]
    //
    // input number:2.759
    // ceil(2.759) = 3
    
    exit get_ceil()
    
    function get_ceil()
    
    	local input = 0
    
    	input = getopt('input number: ')
    	print("ceil("&input&") = "& ceil(input) )
    
    endfunction
    
    
    Topへ
    floor()
    Description
    Returns the largest value that is equal to or less than an actual count
    Syntax
    ret = floor(n)
    Parameters
    n:
    Return Value
    real number:Result
    0:Error or result
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    //[result example]
    //
    // input number:2.759
    // floor(2.759) = 3
    //
    
    exit get_floor()
    
    function get_floor()
    
    	local input = 0
    
    	input = getopt('input number: ')
    	print("floor("&input&") = "& floor(input) )
    
    endfunction
    
    
    Topへ
    log()
    Description
    Returns the natural logarithm (base e) of a given number
    Syntax
    ret = log(e)
    Parameters
    e:
    Return Value
    real number:Result
    0:Error or result
    System Return Value
    ERROR
    0Success
    1Argument error
    14Argument is negative
    Example
    //[result example]
    //
    // input number:2.3123
    // log(2.3123) = 0.838243
    //
    
    exit get_log()
    
    function get_log()
    
    	local input = 0
    
    	input = getopt('input number: ')
    	print("log("&input&") = "& log(input) )
    
    endfunction
    
    
    Topへ
    log10()
    Description
    Returns the common logarithm (base 10) of a given number
    Syntax
    ret = log10(e)
    Parameters
    e:
    Return Value
    real number:Result
    0:Error or result
    System Return Value
    ERROR
    0Success
    1Argument error
    14Argument is negative
    Example
    //[result example]
    //
    // input number:1000
    // log10(1000) = 3.000000
    //
    
    exit get_log10()
    
    function get_log10()
    
    	local input = 0
    
    	input = getopt('input number: ')
    	print("log10("&input&") = "& log10(input) )
    
    endfunction
    
    
    Topへ
    max()
    Description
    Returns the maximum value of array variable
    Syntax
    ret = max(array)
    Parameters
    array:Array to determine the maximum value
    Return Value
    real number:Result
    0:Error or result
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    //[result example]
    //
    // Maximum is 10
    // 
    
    exit Run()
    
    function Run()
    
    	local arr[3] = {5, 10, 2}
    	local max_arr
    
    	max_arr = max(arr)
    
    	print('Maximum is ${max_arr}', stdout)
    
    endfunction
    
    
    Topへ
    min()
    Description
    Returns the minimum value of array variable
    Syntax
    ret = min(array)
    Parameters
    array:Array to determine the minimum value
    Return Value
    real number:Result
    0:Error or result
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    //[result example]
    //
    // Minimum is -1
    // 
    
    exit Run()
    
    function Run()
    
    	local arr[3] = {5, 10, -1}
    	local min_arr
    
    	min_arr = min(arr)
    
    	print('Minimum is ${min_arr}', stdout)
    
    endfunction
    
    
    Topへ
    percent()
    Description
    Returns the percentage of the ratio of value of each element against the summed value in array variable.
    Syntax
    ret = percent(array)
    Parameters
    array:array
    Return Value
    array:Result
    0:Error or result
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    //[result example]
    //
    // 18 is 16.981132%.
    //  9 is 8.490566%.
    //  6 is 5.660377%.
    //  5 is 4.716981%.
    // 10 is 9.433962%.
    // 10 is 9.433962%.
    // 18 is 16.981132%.
    //  2 is 1.886792%.
    //  6 is 5.660377%.
    // 22 is 20.754717%.
    //
    
    exit Run()
    
    function Run()
    
    	local arr[10] = {18, 9, 6, 5, 10, 10, 18, 2, 6, 22}
    	local percent_arr
    
    	percent_arr = percent(arr)
    
    	local i
    
    	loop i=0; i<count(arr); i++
    		print('The rate for which ${arr[i]} accounts is ${percent_arr[i]}%.', stdout)
    	endloop
    
    endfunction
    
    
    Topへ
    pow()
    Description
    Returns the result of raising e (natural logarithm) to a given power (n)
    Syntax
    ret = pow(e,n)
    Parameters
    e:
    n:
    Return Value
    real number:Result
    0:Error or result
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    //[result example]
    //
    // input number_x: 2
    // input number_x: 8
    // pow(2,8) = 256.000000
    //
    
    exit get_pow()
    
    function get_pow()
    
    	local input_x = 0
    	local input_y = 0
    
    	input_x = getopt('input number x: ')
    	input_y = getopt('input number y: ')
    	print("pow("&input_x&","&input_y&") = "& pow(input_x,input_y) )
    
    endfunction
    
    
    Topへ
    sqrt()
    Description
    Returns the square root of a given number
    Syntax
    ret = sqrt(e)
    Parameters
    e:
    Return Value
    real number:Result
    0:Error or result
    System Return Value
    ERROR
    0Success
    1Argument error
    14Argument is negative
    Example
    //[result example]
    //
    // input number:3
    // sqrt(3) = 1.732051
    //
    
    exit get_sqrt()
    
    function get_sqrt()
    
    	local input = 0
    
    	input = getopt('input number: ')
    	print("sqrt("&input&") = "& sqrt(input) )
    
    endfunction
    
    
    Topへ
    stddev()
    Description
    Returns the standard deviation of array variable
    Syntax
    ret = stddev(array)
    Parameters
    array:Array to determine the standard deviation
    Return Value
    real number:Result
    0:Error or result
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    //[result example]
    //
    // Standard deviation is 6.244998
    // 
    
    exit Run()
    
    function Run()
    
    	local arr[3] = {18, 9, 6}
    	local stddev_arr
    
    	stddev_arr = stddev(arr)
    
    	print('Standard deviation is ${stddev_arr}', stdout)
    
    endfunction
    
    
    Topへ
    sum()
    Description
    Returns the summed value of array variable
    Syntax
    ret = sum(array)
    Parameters
    array:Array to sum the values
    Return Value
    real number:Result
    0:Error or result
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    //[result example]
    //
    // The sum total is 6.000000
    //
    
    exit Run()
    
    function Run()
    
    	local arr[3] = {1, 2, 3}
    	local sum_arr
    
    	sum_arr = sum(arr)
    
    	print('The sum total is ${sum_arr}', stdout)
    
    endfunction
    
    
    Topへ

    © Insight Technology, Inc. 1996-2003 All Rights Reserved.