|
|
|
|
- Range for conversion
- Val function and UNICODE
- Various
Val (Function) In french: Val Returns the numeric value of a character string. This feature enables you to perform numeric calculations on the character strings.
Val("143") Â Â // Returns 143 Val("1.67") Â // Returns 1.67 Val("ABC") Â Â // Returns 0 Val("3plus2") // Returns 3 Val("7,5") Â Â // Returns 7 Val("1D2") Â Â // Returns 100 Val("2.5e-2") // Returns 0.025
Syntax
<Result> = Val(<Source string> [, <Base Used>])
<Result>: Real or integer - Numeric value of the string.
- 0 if an error occurred.
<Source string>: Character string Character string to convert into a numeric value. For a real, the separator must be the dot ('.') and the prefixes for scientific notation can be 'E', 'e', 'D' or 'd'. If the separator is a comma, the numbers found after the comma will be ignored. <Base Used>: Character string or integer (optional) Base in which the number is represented. The possible values are as follows:- "d": base 10 (decimal)
- "x": base 16 (hexadecimal)
- "o": base 8 (octal)
- an integer included between 2 and 36
Base 10 is used by default. Remarks Val converts a string into an integer if the value is found between -9.223.372.036.854.775.808 and 9.223.372.036.854.775.807. <Source String> can be in ANSI format or in UNICODE format. As soon as a character of <Source String> cannot constitute a number, Val stops interpreting <Source String> and returns the number corresponding to the characters already read The reals can be converted from base 10 only. In the other bases, the characters found after the "." character (dot) will be ignored.
Related Examples:
|
Unit examples (WINDEV): The Val function
[ + ] Using the WLanguage "Val" function with different databases. For example, it allows you to retrieve the decimal value of a string in Hexadecimal format.
|
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|