{{fbdoc item="title" value="CUBYTE"}}----
Converts numeric or string expression to an unsigned byte (##[[KeyPgUbyte|Ubyte]]##)

{{fbdoc item="syntax"}}##
	[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Cubyte** ( [[KeyPgByval|byval]] //expression// [[KeyPgAs|as]] [[DataType|datatype]] ) [[KeyPgAs|as]] [[KeyPgUbyte|ubyte]]
	
	[[KeyPgType|Type]] //typename//
		[[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] [[KeyPgCast|cast]] ( ) [[KeyPgAs|as]] [[KeyPgUbyte|ubyte]]
	End Type
##
{{fbdoc item="usage"}}##
	//result// = **Cubyte**( //numeric expression// )
	//result// = **Cubyte**( //string expression// )
	//result// = **Cubyte**( //user defined type// )
##
{{fbdoc item="param"}}
	##//expression//##
		a numeric, string, or pointer expression to cast to a ##[[KeyPgUbyte|Ubyte]]## value
	##//datatype//##
		any numeric, string, or pointer data type
	##//typename//##
		a user defined type

{{fbdoc item="ret"}}
	A ##[[KeyPgUbyte|Ubyte]]## value.

{{fbdoc item="desc"}}
	The ##**Cubyte**## function rounds off the decimal part and returns a 8-bit ##[[KeyPgUbyte|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 ##[[KeyPgValuint|Valuint]]##.

{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/casting/cubyte.bas"}}%%(freebasic)
' 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
SLEEP
%%

{{fbdoc item="lang"}}
	- Not available in the //[[CompilerOptlang|-lang qb]]// dialect unless referenced with the alias ##**""__Cubyte""**##.

{{fbdoc item="diff"}}
	- New to ""FreeBASIC""

{{fbdoc item="see"}}
	- ##[[KeyPgCbyte|Cbyte]]##
	- ##[[KeyPgCshort|Cshort]]##
	- ##[[KeyPgCushort|Cushort]]##
	- ##[[KeyPgCint|Cint]]##
	- ##[[KeyPgCuint|Cuint]]##
	- ##[[KeyPgClng|Clng]]##
	- ##[[KeyPgCulng|Culng]]##
	- ##[[KeyPgClngint|Clngint]]##
	- ##[[KeyPgCulngint|Culngint]]##
	- ##[[KeyPgCsng|Csng]]##
	- ##[[KeyPgCdbl|Cdbl]]##

{{fbdoc item="back" value="CatPgCasting|Converting Data Types"}}