These functions are used to coerce values from one basic data type to another.
function integertobyte( int_val : integer ) function integertochar( int_val : integer ) function integertoshort( int_val : integer ) function shorttobyte( short_val : short ) function shorttochar( short_val : short ) function longtobyte( long_val : long ) function longtochar( long_val : long ) function longtoshort( long_val : long ) function longtointeger( long_val : long ) function floattobyte( float_val : float ) function floattochar( float_val : float ) function floattoshort( float_val : float ) function floattointeger( float_val : float ) function floattolong( float_val : float ) function doubletobyte( double_val : double ) function doubletochar( double_val : double ) function doubletoshort( double_val : double ) function doubletointeger( double_val : double ) function doubletolong( double_val : double ) function doubletofloat( double_val : double ) function chartodouble( char_val : character ) function chartofloat( char_val : character ) function chartolong( char_val : character ) function chartoshort( char_val : character ) function chartostring( char_val : character ) function chartointeger( char_val : character ) function stringtochar( char_val : string ) function stringtodouble( char_val : string ) function stringtofloat( char_val : string ) function stringtointeger( char_val : string ) function stringtolong( char_val : string ) function stringtoshort( char_val : string )
In most of these functions, some information can be lost. For example, converting a floating-point number to an integer truncates the decimal portion of the floating point number. Also when a floating-point number is greater than or less than 2.147483e+09, a 32-bit integer is not able to represent the number. In situations like this, the default missing value for the output type is returned. Checking these limits is only implemented in functions that convert to longs, ints, shorts, bytes, and characters.
The character conversion functions (charto....) convert the ASCII value of the character to whatever numeric type is requested. Therefore, conversion of the letter 'a' to an integer yields the value 97.
The stringtochar and chartostring functions are the only conversion functions where the dimension of the output is different than the input. For stringtochar, the output number of dimensions is n - 1 where n is the number of dimensions of the input. The dimension sizes for dimensions 0 through n-1 remain the same. For chartostring the output number of dimensions increases by 1. The new dimension's size is the string length of the longest string in the input parameter plus 1.
NG4.1 Home, Index, Examples, Glossary, Feedback, Ref Contents, Ref WhereAmI?