How I may help
LinkedIn Profile Email me!
Call me using Skype client on your machine

Reload this page Comparison of Functions

Here is the beginnings of my notes comparing functions among different languages (Java, MS-Office/Access, MS-SQL, Oracle).

 

Topics this page:

  • Function calls
  • Overloading Functions
  • Aggregate Functions
  • Numeric Math Functions
  • Trigonometric Functions
  • Text Functions
  • Constants
  • Your comments???
  •  

    Site Map List all pages on this site 
    About this site About this site 
    Go to first topic Go to Bottom of this page


    Set screen Function Calls

      A function is a block of code with a defined name that performs a process.

      Official C# terminology states that a function member includes not just methods, but also indexers, operators, constructors, destructors, and other non-data members of a class or struct.

      In this function call foo(bar1,bar2);

      • parentheses enclose the arguments supplied to the function.
      • a comma separate arguments named bar and bar2.
      • a semi-colon terminates the statement.

      Syntax:

        return_type function_name (parameter1, parameter2) {
            // body of method (Java statements)
        }
      Example:
        int AORR (int length, int width) {
            return length * width
        }

      In this C# programming example:

        System.Console.Write("Hello");

        invokes the write method as an object from class Console stored within a project namespace System.

      With Java, use the "Math." library prefix when using Java's native Math library's methods: abs, ceil, floor, max, min, random, round, sin, cos, tan, sqrt. For example: result = Math.random();

     

      Caution! The word "function" is used in two contexts: users refer to application functions such as "create new account", whereas developers write programmatic functions such as "instantiate component xyz" or "store segment abc".

      webpage article The NIST Dictionary of Algorithms and Data Structures

     
    Go to Top of this page.
    Previous topic this page
    Next topic this page

      Set screen Overloading Java Functions

      Overloading is when a function name is used with different signatures: different number of arguments or a different sequence of argument datatypes.


    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen Aggregate Functions

      Library Function Return Type Parameters Description of value(s) returned
        Least - -- In Oracle: the smallest value among columns in the same row.
        greatest - -- In Oracle: the largest value among columns in the same row.
        avg value -- In Oracle: the average of value for a group of rows
      Math. max - - Oracle: Maximum of all value for groups of rows
      Java: Returns a value equal to the greater of the two arguments input. The datatype of the returned value corresponds to that of the arguments.
      Math. min - - Oracle: Minimum of all values for groups of rows
      Java: Returns a value equal to the lesser of the two arguments input. The datatype of the returned value corresponds to that of the arguments.
        Count - - Oracle: Count of rows of columns.


    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen Numeric Math Functions

      static long abs(long x);

      Library Function Return Type Parameters Description of value(s) returned
        vsize text, num, date, ROWID, etc. -- In Oracle: the number of bytes occupied by the value
        sign numVal -- In Oracle: 1 if numVal is positive, -1 if numVal is negative, 0 if zero.
      Math. abs int/long/float/double int/long/float/double numVal The absolute (positive) value. Returns the same data type as the input argument. (a long if the argument is long, etc.)
      Math. round int/long float/double numVal Java rounds a number to the nearest whole number. Oracle adds a parameter for decimal precision.
      Math. ceil double double numVal The smallest whole number greater than or equal to argument numVal.
      Math. floor double double numVal The largest whole number less than or equal to numVal.
        mod -- float/double numVal The modulus (remainder) for a number and its divisor from a division operation.
        pow double double x, double y x raised to the power of y.
      Math. sqrt double double numValue Returns the square root. If the argument is negative, it returns “NaN” (Not a Number).
        exp double double numValue Returns the exponential constant e raised to the power of a double value
        pow double double x, double y Returns the value of the first argument xraised to the power of the second argument y
        log double double numValue Returns the natural logarithm (base e) of a double value
      Math. random double None A random number between 0 and 1. Simulates the roll of dice in a board game.
        toRadians - numValue Converts into radians an angle specified in degrees.
        toDegrees - numValue Converts into degrees an angle specified in radians.

      The absolute value is used to determine whether a number is odd or even. In Transac-SQL:

        SELECT
          x,
          CASE WHEN ABS(x) % 2 = 1
            THEN 'odd'
            ELSE 'even'
          END
        FROM table

      In VBScript:

        <%
          x = 5
          stat = "even"
          SELECT CASE abs(x) mod 2
            CASE 1: stat = "odd"
          END SELECT
          Response.write x & " is " & stat
        %>

      In JScript:

        <script language='JScript' runat=server>
          var x = 5;
          var stat = "even";
          switch(Math.abs(x) % 2) {
            case 1 : stat = "odd";
          }
          Response.Write(x.toString() + " is " + stat);
        </script>


    Go to Top of this page.
    Previous topic this page
    Next topic this page

      Set screen Trigonometric Functions

      Angles within these trig functions are specified in radians as rather than in degrees.

      Library Function Return Type Parameters Description
        acos double double angle Returns the arc cosine of an angle, in the range of 0.0 through pi
        asin double double angle Returns the arc sine of an angle, in the range of -pi/2 through pi/2
        atan2 double double x, double y Returns the arc tangent of an angle, in the range of -pi/2 through pi/2
        atan double double angle Converts rectangular coordinates (b, a) to polar (r, theta)
      Math. cos double double angle Returns the trigonometric cosine of an angle in radians.
      Math. sin double double angle The sine of the angle specified in radians.
      Math. tan double double angle The tangent of the angle specified in radians.


    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen Text Character Functions

      Library Function Return Type Parameters Description of return value
        length number number In Oracle: Returns the number of characters in the column.
        initcap text -- In Oracle: Initial caplitalize (the first letter of each word in) variables.
        lpad text -- In Oracle: Pre-pends additional filler characters on the left of data in a column.
        rpad text -- In Oracle: Appends additional filler characters on the right of data in a column. Typically used in formatting fixed-space reports:
      dbms_output.put_line( rpad('TABLESPACE',60,' ') ) || rpad('TOTAL(M)',10,' ') || rpad('FREE(M)',10,' '));

        ltrim
      rtrim
      text -- In Oracle: Removes blanks from the left or right of a column.
        substr text 1.column 2.starting position 3.number of positions In Oracle: Removes blanks from the left or right of a column.
        trunc(sysdate) text -- In Oracle: Truncates (removes) the time portion of what is returned from the sysdate system variable.
        to_char text -- In Oracle: Converts to data type values in other data types (such as date and numeric).

      A website external to this site Lowe Lum Carlson Systems' Oracle SQL 8i Tutorials Lesson #11 - Character Functions


    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen Constants

      The Math class provides two double type constants (values which never change):

      • Math.PI ~=3.14 -- The mathematical constant, lower-case Greek letter pi ( π ).
      • Math.E ~=2.718281828459045 -- Leonhard Euler's number e, the base of natural logarithms, such that ln(e^1) = 1
      • No Phi ~=1.618 -- the basis for the Golden Rectangles and Spirals found in nature (in sunflowers, nautilus shells, and the formation of galaxies).


    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Portions ©Copyright 1996-2014 Wilson Mar. All rights reserved. | Privacy Policy |

    Related Topics:

  • Date Functions
  • Java Platform Architecture
  • Free Training!
  • Tech Support

  • How I may help

    Send a message with your email client program


    Your rating of this page:
    Low High




    Your first name:

    Your family name:

    Your location (city, country):

    Your Email address: 



      Top of Page Go to top of page

    Thank you!