Repository navigation
Operator Exponentiate
Home › Operators › Operator ^ (Exponentiate)
Raises a numeric expression to some power
Declare Operator ^ ( ByRef lhs As Double, ByRef rhs As Double ) As Doublelhsrhs
Operator ^ (Exponentiate) returns the result of a base expression (lhs) raised to some exponent expression (rhs). ^ works with double float numbers only, operands of other types will be converted into double before performing the exponentiation. Exponent of a fractional value (1/n) is the same as taking nth root from the base, for example, 2 ^ (1/3) is the cube root of 2.
Neither of the operands are modified in any way.
This operator can be overloaded for user-defined types.
This operation is for Double precision data types only (53 significant bits), and suffers from some inaccuracies in the least significant bits of the number, especially when converting from other data types (e.g. 64-bit data types). This inaccuracy is particularly noticeable when the result is expected to be an exact number, but then finding the result is out by a very small amount. For this reason, never assume that an exponentiation expression will be exactly equal to the value expected, but rather close within some small amount of error. Be wary of using rounding methods such as Int and Fix on the result: if you expect the result to be an integer value, then there's a chance that it might be slightly lower, and will round down to a value that is one less than expected.
This operator exists in C/C++ with a different meaning; in C/C++ it performs a Bitwise Xor.
Returns the exponentiation of a base expression raised to some exponent.
result = lhs ^ rhs
- In the -lang qb dialect, this operator cannot be overloaded.
- None
Dim As Double n
Input "Please enter a positive number: ", n
Print
Print n;" squared is "; n ^ 2
Print "The fifth root of "; n;" is "; n ^ 0.2
SleepOutput:
Please enter a positive number: 3.4
3.4 squared is 11.56
The fifth root of 3.4 is 1.27730844458754Category: Operators
Kind: operator
Reproduced from the FreeBASIC Wiki Manual under the GNU Free Documentation License 1.3 — with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. Copyright © the FreeBASIC project and wiki contributors. See License.
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
- 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