CUBYTE
- Source: https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgCubyte
- Last revised: 2016-03-12
Converts numeric or string expression to an unsigned byte (Ubyte)
Syntax
vb
declare function Cubyte ( byval expression as datatype ) as ubyte
Type typename
declare operator cast ( ) as ubyte
End TypeUsage
vb
result = Cubyte( numeric expression )
result = Cubyte( string expression )
result = Cubyte( user defined type )Parameters
expression
a numeric, string, or pointer expression to cast to a Ubyte value
datatype
any numeric, string, or pointer data type
typename
a user defined type
Return Value
A Ubyte value.
Description
The Cubyte function rounds off the decimal part and returns a 8-bit Ubyte value. The function does not check for an overflow, and results are undefined for values which are less than 0 or larger than 255.
The name can be explained as 'Convert to Unsigned Byte'.
If the argument is a string expression, it is converted to numeric by using Valuint.
Examples
start GeSHi
vb
' Using the CUBYTE function to convert a numeric value
'Create an UNSIGNED BYTE variable
Dim numeric_value As UByte
'Convert a numeric value
numeric_value = CUByte(123.55)
'Print the result, should return 124
Print numeric_value
Sleepend GeSHi
Dialect Differences
- Not available in the -lang qb dialect unless referenced with the alias
__Cubyte.
Differences from QB
- New to FreeBASIC
See also
CbyteCshortCushortCintCuintClngCulngClngintCulngintCsngCdbl
Back to DocToc