{{fbdoc item="title" value="CUSHORT"}}----
Converts numeric or string expression to an unsigned integer (##[[KeyPgUshort|Ushort]]##)

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

{{fbdoc item="ret"}}
	A ##[[KeyPgUshort|Ushort]]## value.

{{fbdoc item="desc"}}
	The ##**Cushort**## function rounds off the decimal part and returns a 16-bit ##[[KeyPgUshort|Ushort]]## value.  The function does not check for an overflow, and results are undefined for values which are less than ##0## or larger than ##65## ##535##.
	
	The name can be explained as 'Convert to Unsigned Short'.
	
	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/cushort.bas"}}%%(freebasic)
' Using the CUSHORT function to convert a numeric value

'Create an USHORT variable
DIM numeric_value AS USHORT

'Convert a numeric value
numeric_value = CUSHORT(36000.4)

'Print the result, should return 36000
PRINT numeric_value
SLEEP
%%
{{fbdoc item="lang"}}
	- Not available in the //[[CompilerOptlang|-lang qb]]// dialect unless referenced with the alias ##**""__Cushort""**##.

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

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

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