{{fbdoc item="title" value="SGN"}}----
Returns the sign part of a number

{{fbdoc item="syntax"}}##
	[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Sgn** ( [[KeyPgByval|byval]] //number// [[KeyPgAs|as]] numtype ) [[KeyPgAs|as]] numtype
##
{{fbdoc item="usage"}}##
	//result// = **Sgn**( //number// )
##
{{fbdoc item="param"}}
	##//number//##
		the number to find the sign of
	##//numtype//##
		a numeric type

{{fbdoc item="ret"}}
	Returns the sign part of ##//number//##.
	- If //number// is greater than zero, then ##**Sgn**## returns ##1##.
	- If //number// is equal to zero, then ##**Sgn**## returns ##0##.
	- If //number// is less than zero, then ##**Sgn**## returns ##-1##.

{{fbdoc item="desc"}}
	The required ##//number//## argument can be any valid numeric expression.
	Unsigned numbers of size greater than or equal to ##[[KeyPgSizeof|SizeOf]]([[KeyPgAny|Any]] [[KeyPgPtr|Ptr]])## will be treated as if they were signed, i.e. if the highest bit is set the number will be treated as negative, and ##-1## will be returned.
	
	**Note:**
		The return type of **##Sgn##** depends on the type of the passed argument (variable or constant, its data type), and of the used backend (gas, gas64, gcc 32-bit, gcc 64-bit):
			**""-""** **##Sgn##** return type for a variable passed as argument:
			~~{{table columns="5" cellpadding="5" cells=" Argument ; gas (32-bit) ; gas64 (64-bit) ; gcc 32-bit (*) ; gcc 64-bit (*) ; [U]BYTE variable ; INTEGER ; INTEGER ; LONG ; LONG ; [U]SHORT variable ; INTEGER ; INTEGER ; LONG ; LONG ; [U]LONG variable ; INTEGER ; INTEGER ; LONG ; LONG ; [U]INTEGER variable ; INTEGER ; INTEGER ; LONG ; LONG ; [U]LONGINT variable ; LONGINT ; INTEGER ; LONG ; LONG ; SINGLE variable ; SINGLE ; LONG  ; LONG  ; LONG ; DOUBLE variable ; DOUBLE ; LONG ; LONG ; LONG "}}
			**""-""** **##Sgn##** return type for a constant passed as argument:
			~~{{table columns="5" cellpadding="5" cells=" Argument ; gas (32-bit) ; gas64 (64-bit) ; gcc 32-bit (*) ; gcc 64-bit (*) ; [U]BYTE constant ; INTEGER ; INTEGER ; INTEGER ; INTEGER ; [U]SHORT constant ; INTEGER ; INTEGER ; INTEGER ; INTEGER ; [U]LONG constant ; INTEGER ; INTEGER ; INTEGER ; INTEGER ; [U]INTEGER constant ; INTEGER ; INTEGER ; INTEGER ; INTEGER ; [U]LONGINT constant ; LONGINT ; INTEGER ; LONGINT ; INTEGER ; SINGLE constant ; SINGLE ; SINGLE ; SINGLE ; SINGLE ; DOUBLE constant ; DOUBLE ; DOUBLE ; DOUBLE ; DOUBLE "}}
			(*): applicable also for clang and llvm
			
	The ##**Sgn**## unary ##[[KeyPgOperator|operator]]## can be overloaded with user defined types.

{{fbdoc item="ex"}}
	{{fbdoc item="filename" value="examples/manual/math/sgn.bas"}}%%(freebasic)
DIM N AS INTEGER = 0

PRINT SGN ( -1.87 )
PRINT SGN ( 0 )
PRINT SGN ( 42.658 )
PRINT SGN ( N )
%%
		The output would look like:
		%%
-1
0
1
0
%%
{{fbdoc item="lang"}}
	- In the //[[CompilerOptlang|-lang qb]]// dialect, this operator cannot be overloaded.

{{fbdoc item="diff"}}
	- None

{{fbdoc item="see"}}
	- ##[[KeyPgAbs|Abs]]##
	- ##[[KeyPgOperator|Operator]]##

{{fbdoc item="back" value="CatPgMath|Math"}}