{{fbdoc item="title" value="CSNG"}}----
Converts numeric or string expression to ##[[KeyPgSingle|Single]]## precision floating point

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

{{fbdoc item="ret"}}
	A ##[[KeyPgSingle|Single]]## precision value.

{{fbdoc item="desc"}}
	The ##**Csng**## function returns a 32-bit ##[[KeyPgSingle|Single]]## value. The function does not check for an overflow, so be sure not to pass a value outside the representable range of the ##[[KeyPgSingle|Single]]## data type. The name can be explained as 'Convert to ""SiNGle""'.
	
	If the argument to ##**Csng**## is a string expression, it is first converted to numeric by using ##[[KeyPgVal|Val]]##.

{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/casting/csng.bas"}}%%(freebasic)
' Using the CSNG function to convert a numeric value

'Create an SINGLE variable
DIM numeric_value AS SINGLE

'Convert a numeric value
numeric_value = CSNG(-12345.123)

'Print the result, should return -12345.123
PRINT numeric_value
SLEEP
%%

{{fbdoc item="diff"}}
	- The string argument was not allowed in QB

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

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