Repository navigation
Modern Math CSgn
Paul Squires edited this page Oct 19, 2026
·
5 revisions
Home › Math Library › Math Library › CSgn
Returns a complex number scaled to modulus 1, or zero for zero.
CSgn( byref z as Complex ) as Complex-
z / CAbs( z ), andCZero( )for zero. This is Mathematica'sSign[z]and the only meaning of sign that survives on ℂ. -
Deliberately different from AfxNova, whose
CSgnreturned aLONG:+1if the real part was positive, else-1if negative, else the same test on the imaginary part. That is a lexicographic tie-break, not a sign, and this header declines to give ℂ an ordering. Code ported from AfxNova gets a compile error at the assignment rather than a silently different number. - The result has modulus 1 and the same argument as the operand.
#import "std/numeric"
using numeric
dim as Complex z = CSet( 3, 4 )
print CToString( CSgn( z ) ) '' 0.6+0.8i
print CAbs( CSgn( z ) ) '' 1 -- always 1
print CToString( CSgn( CZero( ) ) ) '' 0+0iLibrary: Math Library
Category: Math Library
Documented under: Members
tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Lambdas
- Block Strings
- Partial Types
- String Slices
- Embed
- Typed Variadics
- C Header Import
- Foreign Library Linking
- UString
- Fixed-Width Types
- Nullptr
- String Library
- Format
- Array
- Map
- Set
- LinkedList
- OrderedMap
- OrderedSet
- Sorting
- Optional
- Result
- Smart Pointers
- Date and Time (Chrono)
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- PsControls
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- TIKO_COMPILER
- Variable Declarations
- Standard Data Types
- User Defined Types
- Procedures
- Operators
- Control Flow Statements
- Converting Data Types
- Array Functions
- String Functions
- Mathematical Functions
- Bit Manipulation
- Date and Time Functions
- File I/O Functions
- Console Functions
- User Input (Runtime Library)
- User Input Functions (Graphics Library)
- Screen Functions
- 2D Drawing Functions
- Graphics Library Reference
- Graphics Keyword List
- Memory Functions
- Threading Support Functions
- Error Handling Functions
- Operating System Functions
- Preprocessor
- Intrinsic Defines
- Miscellaneous Keywords
- Modularizing