Repository navigation
Modern Math CPow
Paul Squires edited this page Oct 19, 2026
·
5 revisions
Home › Math Library › Math Library › CPow
Raises a complex or real number to a complex or real power.
CPow( byref z as Complex, byref w as Complex ) as Complex
CPow( byref z as Complex, byval p as float64 ) as Complex
CPow( byval x as float64, byref w as Complex ) as Complex- The
^operator resolves to this in all three arrangements. -
Two answers here are .NET's and are wrong, and they are pinned by a test rather than quietly corrected.
CPow( 0, 0 )is1— the zero-exponent test comes first — andCPow( 0, w )is0for every otherw, including negativew, where the true answer is infinite. Kept for source compatibility with both of this header's sources; changing it should be a deliberate act. - For a non-zero base it is
exp( w · log z )evaluated in polar form, so it inheritsCLog's branch cut. -
CPow( z, 0.5 )andCSqrt( z )agree;CSqrtis the more accurate of the two.
#import "std/numeric"
using numeric
print CToString( CPow( CSet( 3, 4 ), 2.0 ) ) '' -6.999999999999998+24.000000000000004i
print CToString( CSet( 3, 4 ) ^ 2.0 ) '' -6.999999999999998+24.000000000000004i -- the operator agrees
print CToString( E ^ CSet( 0, PI ) ) '' -1+1.2246063538223773e-016i -- Euler again, through the operator
print CToString( CPow( CZero( ), CSet( -1, 0 ) ) ) '' 0+0i -- pinned: .NET's answer, and wrongLibrary: 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.
- Home
- What Is tiko-lang
- Quick Start
- Installing on macOS
- Debugging
- Feature Index
- Compatibility
- FAQ
- AI Cheatsheet
- 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)
- Time Zones
- 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