[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 VAL() 
 Convert a character number to numeric type
------------------------------------------------------------------------------
 Syntax

     VAL(<cNumber>) --> nNumber

 Arguments

     <cNumber> is the character expression to be converted.

 Returns

     VAL() returns <cNumber> converted to a numeric value including decimal
     digits.

 Description

     VAL() is a character conversion function that converts a character
     string containing numeric digits to a numeric value.  When VAL() is
     executed, it evaluates <cNumber> until a second decimal point, the first
     non-numeric character, or the end of the expression is encountered.
     Leading spaces are ignored.  When SET FIXED is ON, VAL() returns the
     number of decimal places specified by SET DECIMALS, rounding <cNumber>
     if it is specified with more digits than the current DECIMALS value.  As
     with all other functions that round, digits between zero and four are
     rounded down, and digits between five and nine are rounded up.  When SET
     FIXED is OFF, VAL() returns the number of decimal places specified in
     <cNumber>.

     VAL() is the opposite of STR() and TRANSFORM(), which convert numeric
     values to character strings.

 Examples

     .  These examples illustrate VAL() with SET FIXED ON and SET
        DECIMALS TO 2:

        SET DECIMALS TO 2
        SET FIXED ON
        //
        ? VAL("12.1234")         // Result:   12.12
        ? VAL("12.1256")         // Result:   12.13
        ? VAL("12A12")           // Result:   12
        ? VAL("A1212")           // Result:      0
        ? VAL(SPACE(0))          // Result:      0
        ? VAL(SPACE(1))          // Result:      0
        ? VAL(" 12.12")          // Result:   12.12

 Files   Library is CLIPPER.LIB.


See Also: ROUND() SET DECIMALS SET FIXED STR() TRANSFORM()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson