Revision history for KeyPgSgn


Revision [26735]

Last edited on 2024-01-29 00:13:42 by fxm [added Sgn return type for clang and llvm]
Additions:
~~{{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 "}}
~~{{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
Deletions:
~~{{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 "}}
~~{{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 "}}


Revision [26105]

Edited on 2022-08-10 03:12:49 by fxm [SGN return type depends on passed argument and backend]
Additions:
[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Sgn** ( [[KeyPgByval|byval]] //number// [[KeyPgAs|as]] numtype ) [[KeyPgAs|as]] numtype
##//numtype//##
a numeric type
**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 "}}

{{fbdoc item="filename" value="examples/manual/math/sgn.bas"}}%%(freebasic)
The output would look like:
%%
Deletions:
[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Sgn** ( [[KeyPgByval|byval]] //number// [[KeyPgAs|as]] [[KeyPgInteger|integer]] ) [[KeyPgAs|as]] [[KeyPgInteger|integer]]
[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Sgn** ( [[KeyPgByval|byval]] //number// [[KeyPgAs|as]] [[KeyPgLongint|longint]] ) [[KeyPgAs|as]] [[KeyPgLongint|longint]]
[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Sgn** ( [[KeyPgByval|byval]] //number// [[KeyPgAs|as]] [[KeyPgDouble|double]] ) [[KeyPgAs|as]] [[KeyPgDouble|double]]
{{fbdoc item="filename" value="examples/manual/math/sgn.bas"}}%%(freebasic)
The output would look like:


Revision [26068]

Edited on 2022-06-23 06:46:48 by fxm [only unsigned numbers of size greater than or equal to SizeOf(Any Ptr) are treated as if they were signed]
Additions:
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.
Deletions:
The required ##//number//## argument can be any valid numeric expression. Unsigned numbers 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.


Revision [21135]

Edited on 2016-03-13 10:49:42 by fxm [Formatting]
Additions:


Revision [20521]

Edited on 2016-02-10 16:08:40 by DkLwikki [Update link format]
Additions:
[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Sgn** ( [[KeyPgByval|byval]] //number// [[KeyPgAs|as]] [[KeyPgInteger|integer]] ) [[KeyPgAs|as]] [[KeyPgInteger|integer]]
[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Sgn** ( [[KeyPgByval|byval]] //number// [[KeyPgAs|as]] [[KeyPgLongint|longint]] ) [[KeyPgAs|as]] [[KeyPgLongint|longint]]
[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Sgn** ( [[KeyPgByval|byval]] //number// [[KeyPgAs|as]] [[KeyPgDouble|double]] ) [[KeyPgAs|as]] [[KeyPgDouble|double]]
The ##**Sgn**## unary ##[[KeyPgOperator|operator]]## can be overloaded with user defined types.
- In the //[[CompilerOptlang|-lang qb]]// dialect, this operator cannot be overloaded.
- ##[[KeyPgAbs|Abs]]##
- ##[[KeyPgOperator|Operator]]##
Deletions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Sgn** ( [[KeyPgByval byval]] //number// [[KeyPgAs as]] [[KeyPgInteger integer]] ) [[KeyPgAs as]] [[KeyPgInteger integer]]
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Sgn** ( [[KeyPgByval byval]] //number// [[KeyPgAs as]] [[KeyPgLongint longint]] ) [[KeyPgAs as]] [[KeyPgLongint longint]]
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Sgn** ( [[KeyPgByval byval]] //number// [[KeyPgAs as]] [[KeyPgDouble double]] ) [[KeyPgAs as]] [[KeyPgDouble double]]
The ##**Sgn**## unary ##[[KeyPgOperator operator]]## can be overloaded with user defined types.
- In the //[[CompilerOptlang -lang qb]]// dialect, this operator cannot be overloaded.
- ##[[KeyPgAbs Abs]]##
- ##[[KeyPgOperator Operator]]##


Revision [17684]

Edited on 2015-06-12 06:05:05 by FxMwikki [Suppressed the no-relevant keyword 'Overload' in Syntax]
Additions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Sgn** ( [[KeyPgByval byval]] //number// [[KeyPgAs as]] [[KeyPgInteger integer]] ) [[KeyPgAs as]] [[KeyPgInteger integer]]
Deletions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Sgn** [[KeyPgOverload overload]] ( [[KeyPgByval byval]] //number// [[KeyPgAs as]] [[KeyPgInteger integer]] ) [[KeyPgAs as]] [[KeyPgInteger integer]]


Revision [17109]

Edited on 2014-06-25 14:35:48 by CountingPine [Explain behaviour for unsigned numbers]
Additions:
The required ##//number//## argument can be any valid numeric expression. Unsigned numbers 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.
Deletions:
The required ##//number//## argument can be any valid numeric expression.


Revision [16915]

Edited on 2013-08-12 11:31:33 by CountingPine [Add more overloads; remove pointless section about "uninitialised" variables; etc]
Additions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Sgn** [[KeyPgOverload overload]] ( [[KeyPgByval byval]] //number// [[KeyPgAs as]] [[KeyPgInteger integer]] ) [[KeyPgAs as]] [[KeyPgInteger integer]]
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Sgn** ( [[KeyPgByval byval]] //number// [[KeyPgAs as]] [[KeyPgLongint longint]] ) [[KeyPgAs as]] [[KeyPgLongint longint]]
the number to find the sign of
- 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##.
The required ##//number//## argument can be any valid numeric expression.
DIM N AS INTEGER = 0
Deletions:
the 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.
The required ##//number//## argument can be any valid numeric expression. If ##//number//## is an uninitialized variable, zero is returned.
DIM N AS INTEGER


Revision [14024]

Edited on 2008-12-13 12:54:30 by LaananFisher [Updated: minor formatting]
Additions:
//result// = **Sgn**( //number// )
Deletions:
//result// = **Sgn** ( //number// )


Revision [12444]

The oldest known version of this page was created on 2008-01-18 14:25:50 by JeffMarshall [Updated: minor formatting]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode